Skip to main content

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

propertytypedefaultdescription
activebooltrueWhether the machine is running
machineasset · state_machineThe state machine to run
playerstringNode 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:

methodwhat 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() -> anyThe 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.