A state machine is a diagram that represents the behavior of a system or an object. This diagram consists of nodes connected by lines, similar to a flowchart. Each node represents a state and each connecting line represents a transition between states.
A state machine is only in one state at a time. It remains in the same state until the conditions for a transition are met or when a specific action completes.
For example, a state machine that represents the behaviour of a door might include the opened, closed, and locked states. The door can’t be in the opened and closed state at the same time. A transition from the opened to closed state occurs when someone pushes the door closed. The state machine remains in the closed state until the conditions for another transition are met.
Unity’s Mecanim Animation system uses a state machine to arrange and play animation associated with a character or GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary. Like a traditional state machine, an animation state machineA graph within an Animator Controller that controls the interaction of Animation States. Each state references an Animation Blend Tree or a single Animation Clip. More info
See in Glossary remains in the same state until it satisfies the criteria for a transition. This criteria might be when an animation completes, a specific action completes, or when a set of conditions are true.
Each state includes an animation that plays when the state machine enters the state. This animation might play once or loop while the state machine remains in the state. This animation might be a single animation clipAnimation data that can be used for animated characters or simple animations. It is a simple “unit” piece of motion, such as (one specific instance of) “Idle”, “Walk” or “Run”. More info
See in Glossary or many animation clips blended together.
For example, an Animation state machine for player movement might include states with animation for standing still (idle), walking, running, and jumping. A transition from the idle to the walking state occurs when the user inputs the command to walk. In this case, the transition criteria is true when the user uses an input device to move the character forward.
Use the Animator windowThe window where the Animator Controller is visualized and edited. More info
See in Glossary to create a state machines for a character or GameObject.
An Animation state machine consists of States, TransitionsThe blend from one state to another in a state machine, such as transitioning a character from a walk to a jog animation. Transitions define how long the blend between states should take, and the conditions that activate the blend. More info
See in Glossary, and Events. Use a Sub-State machine to divide larger state machines. For more information, refer to Animation States and Animation transitionsAllows a state machine to switch or blend from one animation state to another. Transitions define how long a blend between states should take, and the conditions that activate them. More info
See in Glossary.