States
A state is a named snapshot of everything an object currently is: where it stands, what colour it is, whether it is visible, which animation is selected.
Switch to a state and the object becomes that snapshot again. That is the whole feature, and it replaces a surprising amount of hand-written logic.
When to reach for one
| You want | States are… |
|---|---|
| A light switch: on and off | exactly right |
| A door: closed, open, locked | exactly right |
| A product in three colourways | exactly right |
| A character walking a path | wrong — that is animation |
| Something that changes by a calculated amount | wrong — that is a patch or script |
The rule of thumb: a fixed number of named situations is a state. Anything continuous is an animation.
Building them
Add a States component to an object, then add a state. It records the object as it stands right now.
To build the next one: add a second state, then change the object while that state is selected. Position it, recolour it, hide it — the state captures as you go.
While a state is selected, editing the object edits that state's snapshot, not the object itself.
That is exactly what you want when building states, and thoroughly confusing when you had forgotten a state was selected and wondered why your change "did not stick" after switching.
Switching between them
From an event, use the Set state step. It takes the state and, optionally, a duration and an easing.
With a duration, the change eases — the object glides from wherever it is to the snapshot rather than jumping. That single field is what turns a state switch into an animation you did not have to author.
| Where you switch from | How |
|---|---|
| An event | the Set state step |
| A patch | the set_states node |
| A script | write activeStateId on the States component |
Reacting to a switch
Two triggers fire on the object whose state changed:
| Trigger | Fires when |
|---|---|
| State active | the object entered the state you picked |
| State inactive | it left that state |
Each event names which state it is watching, so one object can react differently to each of its states. This is how a door plays one sound opening and another closing without any conditions.
Unlike a tap, a state change does not travel up the hierarchy.
Changing a few things without a state
Sometimes you want "like now, but red" without defining a whole state for it. That is the Override properties step: it applies a one-off set of values as a temporary state, with the same duration and easing.
Use it for one-off emphasis (a highlight on hover, a flash on damage) and keep real states for situations the object genuinely has.
What a state covers
A snapshot holds the object's components, so position, rotation, scale, material, visibility and the rest all travel together.
It does not capture children. To switch a group, give each object its own states and switch them from one event — the step's targets take a list.
Where they can catch you out
- A state left selected in the editor quietly absorbs your edits. Check which one is active before wondering why an object keeps reverting.
- States and animation on the same object fight, like any two animation mechanisms. Pick one.
- Removing a component clears it from every state that held it.
- If the selected state no longer exists, the first one is used instead.
Next: Patches