Skip to main content

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 wantStates are…
A light switch: on and offexactly right
A door: closed, open, lockedexactly right
A product in three colourwaysexactly right
A character walking a pathwrong — that is animation
Something that changes by a calculated amountwrong — 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.

This is the part that confuses people

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 fromHow
An eventthe Set state step
A patchthe set_states node
A scriptwrite activeStateId on the States component

Reacting to a switch

Two triggers fire on the object whose state changed:

TriggerFires when
State activethe object entered the state you picked
State inactiveit 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.

These fire on the object itself, not its parents

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.

A state belongs to one object

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