Events and Logic
Use event nodes to respond to scene interactions and build conditional logic with branching and loops.
Events and Logic
Event Nodes
Every visual script starts with an Event node — a node that fires when something happens. The execution flow begins at the event and flows through connected nodes.
Scene Events
| Event | When it fires |
|---|---|
| On Scene Ready | Scene has fully loaded — use for initialization |
| On Update | Every frame (use sparingly for performance) |
| On Timer | After a specified delay (can repeat) |
| On Custom Event | When another script calls Trigger Event with a matching name |
Object Events
| Event | When it fires |
|---|---|
| On Click | Viewer clicks or taps the object |
| On Hover Enter | Cursor or controller enters the object's hover area |
| On Hover Exit | Cursor or controller leaves the hover area |
| On Drag | Object is being dragged (if drag is enabled) |
| On Collision Enter | Physics collision starts |
| On Collision Exit | Physics collision ends |
| On Trigger Enter | Object enters a trigger volume |
| On Trigger Exit | Object leaves a trigger volume |
| On Animation End | An animation clip finishes playing |
| On Visibility Change | Object becomes visible or hidden |
Input Events
| Event | When it fires |
|---|---|
| On Key Down | A keyboard key is pressed |
| On Key Up | A keyboard key is released |
| On Pointer Down | Mouse button or touch starts |
| On Pointer Up | Mouse button or touch ends |
Logic Nodes
If / Else
The If node takes a Boolean input and routes execution down one of two paths:
[Condition] ──▶ [If]──▶ True branch
└──▶ False branch
Branch (Switch)
The Switch node routes execution based on which value matches among multiple cases — useful for menu navigation or multi-state objects:
[Value] ──▶ [Switch]──▶ Case "door": open door
├──▶ Case "light": toggle light
└──▶ Default: do nothing
Compare
Produces a Boolean:
| Node | Output |
|---|---|
| Equals | true if A == B |
| Not Equals | true if A != B |
| Greater Than | true if A > B |
| Less Than | true if A < B |
Boolean Logic
| Node | Output |
|---|---|
| And | true if both inputs are true |
| Or | true if either input is true |
| Not | Inverts the boolean |
Delay
Pauses execution for a specified number of seconds, then continues:
[On Click] ──▶ [Hide Object] ──▶ [Delay: 2s] ──▶ [Destroy Object]
Sequence
Runs multiple execution branches one after another from a single input — useful to trigger several actions from one event without chaining them linearly.
For Each
Iterates over a list of objects (e.g., all children of a parent object):
[Get Children] ──▶ [For Each] ──▶ [Set Color]
│
└──▶ (fires once per child)
Custom Events
Custom Events let you decouple scripts across different objects:
Trigger side (emitter object):
- Use the Trigger Event node
- Set the event name (e.g.,
"game-over") - Optionally attach a data payload
Listener side (any object in the scene):
- Use the On Custom Event node
- Set the same event name — it fires when any emitter triggers it
This pattern lets one object's script communicate with many other objects without direct connections between their graphs.
Practical Example: Door Toggle
[On Click]
└──▶ [Get Variable: isOpen]
└──▶ [If]
├──▶ True ──▶ [Play Clip: "close"] ──▶ [Set Variable: isOpen = false]
└──▶ False ──▶ [Play Clip: "open"] ──▶ [Set Variable: isOpen = true]
This script lives on the door object. When clicked, it checks a boolean variable to decide whether to open or close the door.