

The Animator in Unity controls how a character or object plays animations. It allows you to define different animation states, control transitions between them, and blend multiple animations smoothly based on parameters.
Two core systems inside an Animator Controller are Animator State Machines and Blend Trees. State Machines manage discrete animation states and transitions, while Blend Trees allow smooth interpolation between multiple animations based on one or more parameters.
The Animator Controller is the main asset that manages all your animations for a character. It contains the state machine and optionally blend trees.
Think of it as the “brain” of your character’s animations.
Animator Controller
├── State Machine (Root)
│ ├── Idle State
│ ├── Walk State
│ ├── Run State
│ └── Jump State
└── Parameters
├── Speed (float)
├── IsJumping (bool)
└── AttackTrigger (trigger)
—
The State Machine is like a flowchart of animation states:
State Machine (Root)
├── Idle
│ ↑
│ │ Transition: Speed > 0 → Walk
├── Walk
│ ↑
│ │ Transition: Speed > 5 → Run
├── Run
│ ↑
│ │ Transition: Speed ≤ 5 → Walk
└── Jump
↑
│ Transition: IsJumping == true → Jump
—
A Blend Tree is a special type of state that lets you blend multiple animations smoothly based on one or more parameters.
Blend Tree (1D) - parameter: Speed ├── Idle (Speed = 0) ├── Walk (Speed = 1-5) └── Run (Speed > 5) Unity will automatically interpolate between these based on the current Speed value.
Blend Tree (2D) - parameters: ForwardSpeed, StrafeSpeed ├── Idle (0,0) ├── WalkForward (1,0) ├── WalkBackward (-1,0) ├── StrafeRight (0,1) └── StrafeLeft (0,-1) The character blends all directions smoothly!
—
Parameters are variables used by the Animator to control transitions or blend trees:
Example usage:
Animator anim = GetComponent<Animator>();
anim.SetFloat("Speed", 3.5f);
anim.SetBool("IsJumping", true);
anim.SetTrigger("AttackTrigger");
—
Animator Controller
└── Root State Machine
├── Idle State
├── Move Blend Tree
│ ├── Walk Animation
│ └── Run Animation
├── Jump State
└── Attack State
Parameters: Speed (float), IsJumping (bool), AttackTrigger (trigger)
Animator Controllers in Unity can be used in several ways. Here are three examples that show how to structure them.
—
This is the basic setup without blending. Each animation clip is a state, and transitions are based on parameters.
State Machine: ├── Idle ├── Walk ├── Run └── Jump Parameters: ├── Speed (float) └── IsJumping (bool) Transitions: ├── Idle → Walk : Speed > 0.1 ├── Walk → Run : Speed > 5 └── AnyState → Jump : IsJumping == true
C# Example:
Animator anim = GetComponent<Animator>();
// Set walking speed
anim.SetFloat("Speed", 3.5f);
// Trigger jump
if (Input.GetKeyDown(KeyCode.Space))
{
anim.SetBool("IsJumping", true);
}
This works for simple games but lacks smooth blending between similar animations.
—
A 1D Blend Tree blends multiple animations along a single parameter. Typically used for movement speed.
Blend Tree (1D) - parameter: Speed ├── Idle (Speed = 0) ├── Walk (Speed = 1-5) └── Run (Speed > 5)
As Speed changes, Unity interpolates automatically between Idle → Walk → Run.
C# Example:
Animator anim = GetComponent<Animator>();
// Get input axis for movement
float moveInput = Input.GetAxis("Vertical");
// Update animator parameter
anim.SetFloat("Speed", Mathf.Abs(moveInput));
This makes the character transition smoothly between walking and running without abrupt changes.
—
2D Blend Trees are used when you need two parameters to blend animations. Example: moving forward/backward and strafing.
Blend Tree (2D) - parameters: ForwardSpeed, StrafeSpeed ├── Idle (0,0) ├── WalkForward (1,0) ├── WalkBackward (-1,0) ├── StrafeRight (0,1) └── StrafeLeft (0,-1)
Unity calculates the weighted blend of these four motions based on the two parameters.
C# Example:
Animator anim = GetComponent<Animator>();
float forward = Input.GetAxis("Vertical"); // W/S
float strafe = Input.GetAxis("Horizontal"); // A/D
// Update 2D Blend Tree parameters
anim.SetFloat("ForwardSpeed", forward);
anim.SetFloat("StrafeSpeed", strafe);
This allows the character to move in any direction smoothly and makes animation feel fluid in top-down or third-person games.
—
Blend Trees are essential for modern character movement because they produce smooth, natural animations that react dynamically to player input.