Skip to main content

Udon Basics

This page contains examples of how to use Udon. All examples can be viewed as an Udon Graph or in UdonSharp.

Rotating cube

This behaviour rotates a game object (such as a cube) by 90 degrees every second on its local Y-axis.

An Udon Graph for a spinning cube.

Interact

This behaviour uses Interact to allow players interact with a object to disable it. This can be used for a message or a door that disappears when players click on it, for example. The game object must have a collider component to allow players to interact with it.

An Udon Graph that disables an object when interacting with it. It has several comments. For example, it demonstrates that leaving "instance" empty in the "Get gameObject" node causes it to retrieve to game object that this script is attached to.

Teleport player

This behaviour uses Interact and TeleportTo to teleport the player. The targetPositon transform determines the player's destination position and rotation after teleporting. Don't forget to add a collider component to the targetPosition GameObject.

An Udon Graph program that teleports the player to a target position. Comment points out that "targetPosition" must be defined as "public" to allow setting it in the inspector for instances of this script.

Sending events

This behaviour shows how to interact with other behaviours. UdonBehaviours can communicate with each other through variables and custom events.

An Udon Graph that communicates with other graph programs. Public variables and custom event names from other scripts are specified as constant strings and fed into the "symbolName" parameter of various nodes.