state_machine
animation · 3 properties · Animation
Runs a state machine over a player's clips: it enters its start state, follows auto transitions as their conditions come on, and fades between clips as each transition says. animation.travel heads for a state.
In a scene, state_machine is the node key that applies it. A script reaches each property below as a field on node.state_machine: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.state_machine.get() and node.state_machine.set(table).
Properties
| property | type | default | description |
|---|---|---|---|
active | bool | true | Whether the machine is running |
machine | asset · state_machine | — | The state machine to run |
player | string | — | Node path to the animation player it drives; empty means this node |
Asset types this component references: state_machine.
Script functions
Methods of node.state_machine, the handle a node carrying this component exposes. Each is also a free function on its module, taking the node as its first argument. Every handle also has get(), set(table), has() and remove().
From animation:
| method | what it does |
|---|---|
jump(string) | Cut the state machine to the named state on the next step, with no fade. |
set_condition(string, bool) | Turn on or off a condition that auto transitions wait on. |
state() -> any | The state the machine is in, or nil before it has entered one. |
travel(string) | Head for the named state through the fewest transitions, each fading as it says; a state no transition reaches is cut to directly. |