Getting Started with Unity Animator Controller: Mastering Animation State Control

Created: 2026-02-05Last updated: 2026-07-13

Learn how to manage character animations with Unity's Animator Controller. Covers State Machines, Transitions, Parameters, and Blend Trees in detail.

Tested with: Unity 2022.3 LTS / Unity 6

Walking, running, jumping, attacking — you've got the animation clips ready, but the moment you try to "switch between them based on what's happening," you're not sure where to even start. It's the first wall everyone hits once their character starts moving.

The Animator Controller is Unity's official animation management system. It lets you manage multiple animation clips visually and design "when to play which animation" by connecting states with arrows in a State Machine.

Conceptual image of an Animator Controller. Three state cards — idle, run, and jump — connected by circular arrows into a state machine

What You'll Learn

  • Creating and assigning an Animator Controller (including the Apply Root Motion pitfall)
  • State Machine basics——Entry, Any State, Exit, and state transitions
  • Parameters (Float/Int/Bool/Trigger) and controlling them from scripts
  • Smoothly switching between walking and running with a Blend Tree
  • Layering an upper-body action like "shoot while walking" with Animation Layers
  • Practical Transition setups for jumps, attacks, and combo attacks

Sponsored

Creating an Animator Controller

Method 1: Create Manually

  1. Right-click in the Project window
  2. Select "Create" → "Animator Controller"
  3. Name the file (e.g., "PlayerAnimator")

Method 2: Automatic Creation

When you animate a GameObject in the Animation window, an Animator Controller is created automatically.

Assigning It to a GameObject

  1. Select the GameObject
  2. In the Inspector, choose "Add Component" → "Animator"
  3. Drag and drop the Animator Controller you created onto the Controller field of the Animator component

About Apply Root Motion

The Animator component has a checkbox called "Apply Root Motion".

SettingBehavior
OnMovement and rotation baked into the animation are applied to the character
OffMovement and rotation from the animation are ignored; you control them from scripts
Comparison of Apply Root Motion on vs off. On: the animation itself moves the character forward; off: the character marches in place while a script drives its position

On moves the character using the displacement baked into the animation data (a motion-captured walk carries the character forward as-is). Off just marches in place, and the actual movement is handled by your transform or CharacterController script.

Beginner tip: If you move your character from a script, turn this off. If it stays on, movement gets applied by both the animation and the script, so the character double-moves or slides in unintended ways.

State Machine Basics

State Machine concept diagram. Three state nodes—Idle, Walk, and Jump—are connected by transition arrows, and a Jump Trigger from Any State allows transitioning to Jump from anywhere

When you open the Animator window, several states are provided by default.

StateDescription
EntryThe state where animation transitions start
Any StateA state that can transition to any state from anywhere
ExitReturns from a Sub-State Machine to the parent layer (in the root layer, it goes back to the default state right after Entry)

How Exit behaves: When used inside a Sub-State Machine, Exit hands control back to the parent State Machine. In a root-level State Machine, transitioning to Exit routes through Entry and returns to the default state.

Creating States

  1. Right-click on an empty area in the Animator window
  2. Select "Create State" → "Empty"
  3. Assign an animation clip to the Motion field

Alternatively, drag and drop an animation clip directly from the Project window, and a state is created automatically.

Creating Transitions

  1. Right-click the source state
  2. Select "Make Transition"
  3. Click the destination state

Transition Settings

SettingDescription
Has Exit TimeOn: transitions after the animation finishes. Off: transitions immediately
Transition DurationDuration of the transition (how smooth the blend is)
ConditionsConditions that trigger the transition
Sponsored

Using Parameters

Parameters are used for communication between your scripts and the Animator Controller.

Parameter Types

TypeUse Case
FloatFloating-point numbers (e.g., movement speed)
IntIntegers (e.g., ammo count)
BoolTrue/false values (e.g., whether the character is walking)
TriggerOne-shot flags (e.g., jump)
Comparison of the four Parameter types: Float (Move Speed), Int (Ammo Count), Bool (Is Walking), and Trigger (Jump), shown as four cards acting as the bridge between script and Animator

Creating Parameters

Click the "Parameters" tab on the left side of the Animator window and add parameters with the "+" button.

Controlling the Animator from Scripts

using UnityEngine;

public class PlayerController : MonoBehaviour
{
    private Animator animator;

    void Start()
    {
        animator = GetComponent<Animator>();
    }

    void Update()
    {
        // Get movement input
        float horizontal = Input.GetAxis("Horizontal");
        float vertical = Input.GetAxis("Vertical");
        Vector3 movement = new Vector3(horizontal, 0, vertical);
        float speed = movement.magnitude;

        // Set the Animator parameter
        animator.SetFloat("Speed", speed);

        // Jump input
        if (Input.GetKeyDown(KeyCode.Space))
        {
            animator.SetTrigger("Jump");
        }
    }
}

Parameter Setter Methods

animator.SetBool("isWalking", true);
animator.SetFloat("Speed", 5.0f);
animator.SetInteger("AmmoCount", 10);
animator.SetTrigger("Jump");

Using Blend Trees

A Blend Tree smoothly blends multiple animations based on the value of a parameter.

Creating a Blend Tree

  1. Right-click on an empty area in the Animator window
  2. Select "Create State" → "From New Blend Tree"
  3. Double-click the Blend Tree to open its editor
  4. Choose a "Blend Type" (usually "1D")
  5. Choose a "Parameter" (e.g., "Speed")
  6. Add animation clips and set their Thresholds

Example:

  • Idle - Threshold: 0
  • Walk - Threshold: 0.5
  • Run - Threshold: 1.0
Conceptual diagram of a 1D Blend Tree. Idle (0), Walk (0.5), and Run (1.0) sit along a Speed slider, and at a knob position around 0.75 the Walk and Run animations blend together

Now, when Speed is at an in-between value, the neighboring animations mix automatically. The "pop" of switching disappears, and walk-to-run transitions become smooth.

Sponsored

Using Animation Layers

Animation Layers let you stack multiple State Machines and play them together. Use them when you want one character to do "movement on the lower body, a different action on the upper body" at the same time.

Take "shoot while walking" as an example. You play the walking motion on a Base Layer (lower body) and the shooting motion on an Upper Body Layer, on separate layers. Then you use an Avatar Mask to say "this layer only drives the upper-body bones," so the shooting motion is layered on top without disturbing the walk.

Concept diagram of Animation Layers. A Base Layer drives the lower-body walk and an Upper Body Layer drives the shooting; an Avatar Mask applies the upper layer to the upper body only, compositing them into "shoot while walking"

Layer Settings

SettingDescription
WeightThe layer's weight (0–1). 0 disables it, 1 fully overrides
BlendingOverride or Additive
MaskWhich body parts the layer applies to (specified via Avatar Mask)

Cramming attack, hit, and shoot all into the movement State Machine causes a combinatorial explosion, but splitting them into layers lets you manage "lower-body state × upper-body state" independently.

Hands-On: Movement, Jump, and Attack in One Controller

The hero of a 3D action game, the player character of a top-down ARPG, a soulslike enemy — the genres differ, but a character's foundation is the same combination: "movement (Blend Tree) + jump and attack interrupts." Let's assemble the pieces you've learned into a single Animator Controller.

Overall diagram of the Animator Controller built in this section. Movement is handled by a Speed-driven Blend Tree, Jump interrupts from Any State via a Trigger, and Attack goes back and forth with the move state via a Trigger and an automatic exit-time transition

Example 1: Movement Animation (Blend Tree + Script)

using UnityEngine;

public class MovementAnimator : MonoBehaviour
{
    [SerializeField] private float walkSpeed = 2f;
    [SerializeField] private float runSpeed = 5f;

    private Animator animator;
    private CharacterController controller;

    // Hash the parameter name for better performance
    private static readonly int SpeedHash = Animator.StringToHash("Speed");

    void Start()
    {
        animator = GetComponent<Animator>();
        controller = GetComponent<CharacterController>();
    }

    void Update()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        Vector3 move = new Vector3(h, 0, v);

        // Run check (Shift key)
        float targetSpeed = Input.GetKey(KeyCode.LeftShift) ? runSpeed : walkSpeed;

        // Normalize to match the Blend Tree Thresholds (0-1)
        // move.magnitude reaches sqrt(2) (~1.41) on diagonal movement, so clamp it
        float normalizedSpeed = Mathf.Clamp01(move.magnitude) * (targetSpeed / runSpeed);
        animator.SetFloat(SpeedHash, normalizedSpeed);

        // Movement
        controller.Move(move.normalized * targetSpeed * Time.deltaTime);
    }
}

Performance tip: Hashing parameter names with Animator.StringToHash avoids string comparisons every frame. It pays off for frequently called methods like SetFloat and SetBool. There's a second benefit: typo protection — a misspelled parameter name doesn't raise an error, it just silently does nothing, so consolidating names into hash constants in one place makes mistakes far easier to spot.

Example 2: Jump Animation

// Transition setup from Any State to Jump:
// - Conditions: Jump (Trigger)
// - Has Exit Time: off
// - Transition Duration: 0.1

void Update()
{
    if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
    {
        animator.SetTrigger("Jump");
    }
}

Example 3: Attack Animation (with Combo Support)

// Transition setup:
// - Idle to Attack: Conditions: Attack (Trigger), Has Exit Time: off
// - Attack to Idle: Has Exit Time: on (auto-transitions after the attack animation ends)

void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        animator.SetTrigger("Attack");
    }
}

Mashing warning (Triggers are "reservations"): Click again mid-attack, and that SetTrigger doesn't vanish — it stays pending as a reservation, and a second attack fires on its own the instant you return to Idle. If you don't want mashing to misfire, either ignore input during the attack (only call SetTrigger when attacking is allowed) or clear stale reservations with animator.ResetTrigger("Attack") when an attack starts. Flip it around, though, and this "reservation" behavior is the foundation of input buffering for fighting-game-style combos.

Two points matter most.

  • Movement is a "value"; jump and attack are "signals": Leave continuously changing movement to a Float + Blend Tree, and let one-shot events interrupt via Triggers. The whole art of choosing among the four parameter types boils down to this one sentence.
  • "Going in" is Has Exit Time off; "coming back" is on: React to input instantly (off), and let motions play to the end before automatically returning (on). Most cases of "my attack gets cut off" or "it never returns after attacking" come from mixing these two up.

As your character roster grows, you can reuse this whole structure and swap only the clips inside — that's the Animator Override Controller, up next.

Animator Override Controller

An Animator Override Controller lets you reuse the structure of an existing Animator Controller (State Machine, Transitions) while swapping out only the animation clips.

Use Cases

  • Enemy variations (same movement, different look)
  • Swapping attack motions per weapon
  • Character skins

How to Create One

  1. Right-click in the Project window → Create → Animator Override Controller
  2. Set the base Animator Controller in the "Controller" field
  3. Replace the animations shown in the list
// Swapping dynamically from a script
public AnimatorOverrideController slimeOverride;
public AnimatorOverrideController goblinOverride;

void SetEnemyType(EnemyType type)
{
    animator.runtimeAnimatorController = type == EnemyType.Slime
        ? slimeOverride
        : goblinOverride;
}

Bonus: Good Things to Know in Advance

Once you can build an Animator Controller, these topics come into view next. Even just knowing the names keeps you from getting lost.

  • You can call code mid-animation (Animation Events): "Play a footstep the moment the foot lands" or "spawn the damage hitbox right at the swing" — the standard tool is an Animation Event placed on the clip that calls a function in your script.
  • Off-screen Animators can be skipped automatically (Culling Mode): Setting the Animator component's Culling Mode to Cull Update Transforms reduces the cost of characters the camera can't see. It pays off in games with lots of characters on screen.
  • Humanoid vs Generic is an import-settings topic: The Humanoid setup for sharing animations between human-shaped characters is covered in the 3D model import guide. And 2D sprite animation is driven by this very same Animator Controller (see the 2D animation guide).

Summary

The Animator Controller is Unity's official animation management system.

  • Manage multiple animations visually with the State Machine
  • Control animations from scripts with Parameters
  • Set up transitions between animations with Transitions
  • Blend multiple animations smoothly with Blend Trees
  • Layer multiple animations with Animation Layers

Start with just three states — Idle, Walk, and Jump. What "states" does your character have?

Once you have these basics down, the next step is techniques specific to 3D characters. 8-directional movement (2D Blend Trees), upper-body-only control (Avatar Masks), and when to use Root Motion are covered in 3D Character Animation in Practice.

Further Learning