【VRChat】Mastering User Input Detection: Utilizing Interact and Input Events

Created: 2025-12-19

Input detection methods for player interaction with worlds. Learn implementation patterns for Interact events, VRChat Input Events, and keyboard/VR controller input.

Overview

An interactive world is one that provides some response to player actions (interactions). Providing input methods for players to operate gimmicks is fundamental to world creation.

This article explains the main methods for receiving input from players in UdonSharp. We'll learn from the simplest and most versatile Interact event to methods for detecting specific keyboard and VR controller button inputs.

The Most Basic Input: Interact Event

Interact event operation example

Interact is the most basic interaction built into VRChat. Players can trigger the Interact event by performing the following actions toward a tooltip (operation description) that appears when they approach an object and aim at it:

  • Desktop Mode: Press the V key
  • VR Mode: Pull the controller trigger (index finger button)

To handle this event, override the Interact method in your UdonSharp script.

using UdonSharp;
using UnityEngine;

public class SimpleInteract : UdonSharpBehaviour
{
    public override void Interact()
    {
        Debug.Log("Object was clicked!");
    }
}

Requirements for Interact to Work

For the Interact event to fire, the target GameObject must meet the following conditions:

  1. Collider Component: The object needs a Collider component such as Box Collider or Sphere Collider attached. This allows VRChat's system to recognize "where can be clicked."
  2. Udon Behaviour Component: An Udon Behaviour component with an UdonSharp script containing the Interact method is required.
  3. Interaction Text: Some text (e.g., "Press") must be entered in the Interaction Text field of the Udon Behaviour component. This becomes the tooltip displayed to players.
  4. Distance: The player must be within a certain distance from the object (default is about 2 meters). This distance can be adjusted with the Proximity field.

If any of these conditions is missing, Interact won't function. If there's no response, first check these settings in the Inspector.

Advanced Input Detection: The Input Class

Interact is convenient but can only detect a single "click" action. To handle more diverse inputs like jumping, dashing, or opening a menu, use Unity's Input class. Input class methods are mainly used within the Update event to monitor input every frame.

1. Detecting Keyboard Input (Desktop)

To detect when a specific key is pressed, use Input.GetKeyDown().

  • Input.GetKeyDown(KeyCode.Space): Returns true at the moment the Space key is pressed.
  • Input.GetKey(KeyCode.W): Returns true continuously while the W key is held down.
  • Input.GetKeyUp(KeyCode.LeftShift): Returns true at the moment the left Shift key is released.
void Update()
{
    // Call reset processing the moment the R key is pressed
    if (Input.GetKeyDown(KeyCode.R))
    {
        ResetGimmick();
    }
}

void ResetGimmick()
{
    Debug.Log("Resetting gimmick.");
}

2. VRChat Input Events (Recommended)

Input Events debug test

Directly specifying keyboard keys is often inappropriate since VR users won't be able to use that functionality. To implement input that works for both VR and desktop, the best practice is to use VRChat-provided Input Events.

Input Events are events that you override, similar to Interact.

using UdonSharp;
using UnityEngine;
using VRC.Udon.Common;

public class InputEventExample : UdonSharpBehaviour
{
    // Called when jump button is pressed/released
    public override void InputJump(bool value, UdonInputEventArgs args)
    {
        if (value) // true = pressed, false = released
        {
            Debug.Log("Jump button was pressed!");
        }
    }

    // Called when use button is pressed/released
    public override void InputUse(bool value, UdonInputEventArgs args)
    {
        if (value)
        {
            Debug.Log("Use button was pressed!");
        }
    }
}

Major Input Events

Event NameTrigger Condition
InputJumpJump button (Space / A・X button)
InputUseUse button
InputGrabGrab button
InputDropDrop button
InputMoveHorizontalHorizontal movement input
InputMoveVerticalForward/backward movement input
InputLookHorizontalHorizontal look input
InputLookVerticalVertical look input

3. Unity Input Manager (Auxiliary Method)

Using "logical button names" defined in Unity's standard Input Manager is also possible. However, the above Input Events work more reliably in VRChat environments.

Use Input.GetButtonDown("ButtonName") to request input by button name.

  • Input.GetButtonDown("Jump"): Returns true at the moment the button assigned to "Jump" (default: keyboard Space key, VR controller A/X button, etc.) is pressed.
  • Input.GetAxis("Horizontal"): Returns the input value (-1.0 to 1.0) of the axis assigned to "Horizontal movement." Corresponds to keyboard A/D keys or VR controller stick left/right input.
void Update()
{
    // If jump button is pressed, launch the player upward
    if (Input.GetButtonDown("Jump"))
    {
        // Get your own information with Networking.LocalPlayer
        Networking.LocalPlayer.SetVelocity(new Vector3(0, 5f, 0));
    }
}

Major Logical Button Names

Button NameDefault Key (Desktop)Default Button (VR)Use
JumpSpaceA / X ButtonJump
GrabGGrip ButtonGrab objects (separate from VRChat standard grab)
UseEUse ButtonUse objects (separate from VRChat standard use)
Fire1Left ClickTriggerAttack, confirm
HorizontalA / D KeysLeft Stick left/rightHorizontal movement
VerticalW / S KeysLeft Stick up/downForward/backward movement

These logical names can be checked and customized in Unity's menu [Edit] > [Project Settings] > [Input Manager].

Choosing Between Interact and Input

Choosing between Interact and Input
  • When to use Interact:

    • Gimmicks that directly operate specific objects (buttons, door handles, levers, etc.).
    • When the intuitive "click" operation is appropriate.
    • When you want to provide the most basic operation without worrying about VR/desktop differences.
  • When to use Input:

    • When implementing player abilities (jump, dash, etc.).
    • When implementing global operations not dependent on specific objects (opening menus, switching viewpoints, etc.).
    • When you want to handle complex input that Interact can't express, such as holding buttons or analog input (stick tilt).

In most cases, you'll combine these two to build gimmicks. For example, you might implement "enter a vehicle with Interact, and while inside, control it with Input."

Summary

  • The simplest way to receive input from players is using the Interact event.
  • Collider and Interaction Text settings are essential for Interact to work.
  • To support both VR and desktop, using VRChat-provided Input Events (InputJump, InputUse, etc.) is the best practice.
  • Use Input class methods in Update when finer control is needed.
  • The basic distinction is: Interact for operations on objects, Input Events / Input class for operations on the player themselves.

Designing how players interact with the world is at the heart of what makes world creation fun.