Unity Foundations·From empty scene to playable build

Animation and timelines

Drive an Animator with states and parameters, and sequence cutscenes with Timeline.

Beginner 12 min read Lesson 4 of 300 Challenge included
What you will be able to do
  • Build states and transitions in an Animator Controller.
  • Use a trigger for one-shot actions and a float or bool for ongoing states.
  • Drive parameters from a script.
  • Sequence cutscenes with Timeline tracks.

In plain English

An Animator is the component that plays animations through a controller made of states and transitions. A parameter is a variable on the Animator, such as a bool, float or trigger, that a script can change to tell the controller what to do. A trigger is a one-shot parameter you set to fire a transition like a jump, while a bool or float describes an ongoing state such as running. Timeline is a sequencer that arranges animation clips, audio and activation tracks into a cutscene on a single time ruler.

Step by step

  1. 1Add an Animator component and assign an Animator Controller.
  2. 2Create a state and a transition in the Animator window.
  3. 3Add a trigger parameter and a transition to a jump state.
  4. 4Set the trigger from a script when the player jumps.
PlayerAnimator.csC#
using UnityEngine;

public class PlayerAnimator : MonoBehaviour
{
    [SerializeField] private Animator animator;

    private void Update()
    {
        if (Input.GetButtonDown("Jump"))
        {
            animator.SetTrigger("Jump");
        }
    }
}

Common mistakes

  • Naming the parameter in code with a different case than in the controller fails silently, so the animation never changes.
  • Using a trigger for an ongoing state such as running fires once and never re-evaluates; use a bool or float instead.
  • Hardcoding cutscene logic onto gameplay objects couples a cinematic to one scene and makes it hard to reuse.
  • Forgetting to assign the Animator reference in the Inspector leaves it null and causes a runtime error.
Your turn

Trigger a jump

Easy

Write an Update method that sets the Jump trigger on the Animator when the jump button is pressed.

CSHARP · starter
using UnityEngine;

public class PlayerAnimator : MonoBehaviour
{
    [SerializeField] private Animator animator;

    private void Update()
    {
    }
}
Check your understanding before moving on.
Knowledge checkQuestion 1

Which parameter type is best for a one-shot action such as a jump?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Saving and loading
Lesson 4 of 300 · 0% of course