Add Your First Interactive Button
Once you can open a VRChat world project and test a basic scene, the next useful step is making one object react when a player interacts with it.
This guide builds a simple local button with UdonSharp. Pressing the button toggles a separate target object on or off. That is deliberately small: it teaches the Interact() event, public inspector references, colliders, and testing without adding networking yet.
Start with a button that only changes what the local player sees. Shared synced state comes later, after the simple interaction works.
- Create a visible button object with a Collider.
- Create a separate target object the button will show or hide.
- Add a small UdonSharp script with
Interact(). - Assign the target object in the Inspector and test with Build & Test.
This first button is local-only. It is perfect for learning the interaction path. If every player needs to see the same state, move to synced variables, ownership, and the existing synced-toggle examples after this works.
What You Are Making
You will make three things:
- a button object players can interact with
- a target object that appears or disappears
- one UdonSharp script that toggles the target
Use this for a first test, not as the final version of every world system. A local button is good for personal visual feedback, private hints, local effects, tutorial panels, or learning how Udon hooks into scene objects.
Before You Start
Make sure:
- the project is a VRChat Worlds project
- Unity opens cleanly through Creator Companion
- the VRChat SDK menu appears
- the Console has no red compile errors
- you have a simple scene that already works in Build & Test
If the project is broken before you add the button, pause here and use Fix Your First Broken VRChat Project.
1. Create The Button Object
In your scene:
- Create a small cube, cylinder, or other obvious button shape.
- Name it
LocalToggleButton. - Place it somewhere easy to reach.
- Add or confirm a Collider component.
- Make sure the button stays visible after the interaction.
Do not use the button itself as the target object for this first test. If the button hides itself, you may not be able to click it again.
2. Create The Target Object
Create a separate target object:
- Add a cube, sign, light prop, or simple marker.
- Name it
ToggleTarget. - Put it near the button so the change is obvious.
- Leave it active for the first test.
The target can be any GameObject you want to show or hide. Keep it simple until the script is working.
3. Create The UdonSharp Script
In the Project window, create a script named FirstInteractiveButton.cs.
Use this script:
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class FirstInteractiveButton : UdonSharpBehaviour
{
[Header("Object this button shows or hides")]
public GameObject targetObject;
private bool isVisible = true;
private void Start()
{
if (targetObject != null)
{
isVisible = targetObject.activeSelf;
}
}
public override void Interact()
{
if (targetObject == null)
{
return;
}
isVisible = !isVisible;
targetObject.SetActive(isVisible);
}
}
This is intentionally small. The script checks whether a target is assigned, flips a boolean, and applies that state to the target object.
4. Attach And Assign It
On LocalToggleButton:
- Add the UdonSharp behaviour or Udon Behaviour that uses your
FirstInteractiveButtonprogram. - Assign
ToggleTargetto thetargetObjectfield. - Keep the Collider on the button object.
- Save the scene.
For a 3D object interaction, the interactable object needs a Collider and an Udon behaviour. If either is missing, Interact() will not fire when expected.
5. Test The Interaction
Use a small test loop:
- Clear the Console.
- Save the scene.
- Enter Play Mode or use VRChat Build & Test depending on what you are checking.
- Interact with the button.
- Confirm the target object turns off.
- Interact again and confirm it turns back on.
If the object toggles twice, your first button works.
6. Understand What Is Local
This script does not synchronize state.
That means:
- it teaches the safest first interaction pattern
- it avoids ownership and late-joiner problems
- it is not the right final pattern for shared doors, shared lights, game state, or everyone-sees-it switches
When the button needs to affect everyone in the instance, use a synced example such as Global Toggle Switch (Synced) and read Udon Networking Decision Guide.
Common Beginner Problems
Help! Nothing happens when I click the button.
Check that the button object has a Collider, has the UdonSharp/Udon behaviour attached, and has the target assigned in the Inspector. Also check the Unity Console for compile errors.
Help! The button disappeared and I cannot turn it back on.
You probably assigned the button object as its own target. Use a separate target object so the button remains clickable.
Help! Other players do not see the toggle.
That is expected for this first local version. Move to synced variables, ownership, and the synced toggle examples when shared state matters.
Help! The script will not compile.
Make sure the file name and class name match, the project has UdonSharp available through the Worlds SDK, and there are no other red Console errors blocking compilation.
Should I use a Unity UI Button instead?
Use this guide for a physical 3D world object. For 2D UI, use the VRChat UI-events path and make sure the UI setup matches VRChat's allowed event targets.
What To Build Next
After this works, choose one next step:
- Add a Basic Teleport Pad to learn player movement.
- Add a Return to Spawn Button to make a practical utility.
- Add a Global Toggle Switch (Synced) when everyone needs to see the same state.
- Read the UdonSharp Starter Examples Index when you are ready for a wider path.
Final Check
Your first interactive button is ready when:
- the button has a Collider
- the UdonSharp behaviour is attached
targetObjectis assigned- the Console has no red compile errors
- the target toggles off and on during testing
- you understand whether the behavior is local or synced
That is enough for a first Udon interaction. Keep the first win small, then build the next system deliberately.
Helpful Follow-Up Pages
- UdonSharp Guide
- UdonSharp Starter Examples Index
- VRChat Prefab Hub
- Tutorials Guide Hub
- Fix Your First Broken VRChat Project
Official References
- VRChat Udon - reviewed 2026-05-27.
- VRChat Udon Basics - reviewed 2026-05-27.
- VRChat Udon Event Nodes - reviewed 2026-05-27.
- VRChat UdonSharp - reviewed 2026-05-27.
- VRChat Udon Networking - reviewed 2026-05-27.
- VRChat Udon Network Variables - reviewed 2026-05-27.
- VRChat UI Events - reviewed 2026-05-27.