Each state has a list of Actions to execute when active.
Each Action has a specific purpose: To play an animation, to move a game object towards a target, to test for a collision etc.
Simple Actions can be combined to create complex behaviors.
Actions are activated in the order they are listed, from top to bottom. You can drag and drop actions to re-order them.
IMPORTANT: If an Action triggers a transition, the transition happens immediately and the Actions below it are not executed.
Action Life Cycle
Actions are activated when the State they belong to becomes active.
When activated, actions Start, and every frame they Update until they Finish or the state is Exited.
Each frame every Action in the list that has not finished is updated in turn from top to bottom.
Actions are color coded in the State Inspector to indicate when they are active. For example:
After pressing Play the Intro state becomes active and all of its Actions are activated.
After 1 second, the Camera Fade In Action is complete. The action fades to show that it is finished.
10 seconds after the state was activated, the Wait Action is complete and fades out.
IMPORTANT: Remember Actions run concurrently, the Wait action is running the whole time!
Actions that need to run in sequence should be in separate states linked by transitions.
What does "finish" mean?
Each Action has its own criteria for finishing. The criteria is generally obvious from the Action:
Many Actions have an "Every Frame" option that tells them to repeat every frame:
- Every Frame set to True: The Action repeats every frame and doesn't finish until the state is exited.
- Every Frame set to False: The Action executes once and is finished.
When all Actions on a state have finished, a FINISHED event is sent to the state machine.
You can use this event to transition to a new state.