Skip to content

States

A state runs actions when active:

  • Walking: While in this state, play a walk animation and footstep sounds.
  • Idle: Continuously scans for nearby enemies and sends an alarm event if one is found.
  • Running: Decreases sprint energy over time and transitions to walk when energy reaches zero.

Transitions to other states are triggered by events:

Local Transition

When an event triggers a transition, the current state exits (its actions stop), and the FSM enters the new state, starting its actions.

Start State

The Start State is the state that is entered when the FSM starts running:

Start State

Every FSM must have a Start State.

End State

A state can be marked as an End State:

End State

End States are terminal states - once reached, no further transitions can occur. When all active regions reach End States, the FSM stops running. You can use End States to cleanly stop an FSM after completing a task.

An FSM can have multiple End States:

multiple End States

Advanced Topics

  • Sub-States: A state can contain nested states to organize complex behaviors. Learn more »
  • Regions: States in different regions can run in parallel. Use regions to model behaviors that occur simultaneously. Learn more »