Skip to main content

๐ŸŽฌ Lesson 9.4: Timeline โ€” Building a Cutscene (Mini-Project)

Particles and post-processing make a moment look good; a cutscene makes it land. In this mini-project you'll use Timeline to choreograph a short scripted sequence โ€” a camera sweep, an object animating, a music sting โ€” and fire it from gameplay. It ties the whole VFX & Cinematics module together.

๐ŸŽฏ Learning Objectives

By the end of this lesson, you will be able to:

  • Create a Timeline asset and drive it with a PlayableDirector
  • Work with the core track types: Animation, Activation, Audio, and Cinemachine
  • Blend between Cinemachine cameras on a Cinemachine Track
  • Use a Signal to run code at an exact moment in the timeline
  • Trigger a cutscene from gameplay and hand control back to the player when it ends

Estimated Time: 50 minutes  ยท  Prerequisite: Lesson 9.3 (Post-Processing) & Module 1 (Animation)

In This Lesson

What Timeline Is

Timeline is Unity's track-based sequencing tool. Where the Animator picks one clip based on game state, Timeline lays out many things on a shared clock โ€” animations, camera cuts, audio, particle activations, and code callbacks โ€” and plays them in perfect sync. It's how you author intros, scripted moments, victory sequences, and cutscenes.

Two pieces work together: a Timeline asset (the reusable sequence, saved in your project) and a PlayableDirector component (the thing in the scene that plays a Timeline asset and binds its tracks to real objects).

๐Ÿ“– Definition

PlayableDirector: the component that plays a Timeline. It holds the Timeline asset (the "Playable"), the wrap mode, whether it plays on Awake, and the bindings that connect each track to a specific GameObject in the scene.

Creating a Timeline

  1. Install Timeline and Cinemachine from the Package Manager if they aren't already (Cinemachine is what we'll use for cameras).
  2. Create an empty GameObject named CutsceneDirector.
  3. Open Window โ–ธ Sequencing โ–ธ Timeline. With CutsceneDirector selected, click Create โ€” Unity adds a PlayableDirector and saves a new .playable Timeline asset (put it in an Assets/Cutscenes folder).
  4. You now have an empty timeline ready for tracks.

โœ… Pro Tip

Give the director its own GameObject rather than hanging it off the player or camera. A cutscene is a scene-level thing; keeping it separate makes bindings and re-use far clearer.

Reading the Timeline Window

The Timeline window is a horizontal time ruler with stacked tracks. Each track holds clips you drag along the ruler; the white playhead marks the current time. Add a track with the + button (or right-click the track list). Here is the cutscene we're about to build, drawn exactly as the Timeline window lays it out:

The Unity Timeline window showing a cutscene A recreation of Unity's Timeline window: a track list on the left (Cinemachine, Animation: Door, Activation: VFX, Audio: Music, Signals) and a time ruler on the right with clips laid along each track, a playhead near the start, and two Cinemachine camera clips that overlap to form a blend. Timeline CutsceneDirector โ–พ 0:000:010:02 0:030:040:05 ๐ŸŽฅ Cinemachine Animation ยท Door Activation ยท VFX Audio ยท Music Signals CM vcam: Wide CM vcam: CloseUp Door_Open VFX active Music_Reveal.wav OnCutsceneEnd
Figure 1: The Timeline window (faithfully recreated). Clips sit along each track; the two overlapping Cinemachine clips create a camera blend. The red diamond is a Signal that fires code when the playhead reaches it.

The common tracks:

  • Animation Track โ€” bind a GameObject and record or drop Animation clips (e.g. a door swinging open).
  • Activation Track โ€” turns a GameObject on for the clip's duration (great for switching a particle effect on at the right beat).
  • Audio Track โ€” plays an AudioClip in sync.
  • Cinemachine Track โ€” sequences and blends virtual cameras (next section).
  • Signal Track โ€” emits Signals your code reacts to.

Cinemachine Camera Blends

The magic of a cutscene is the camera. Rather than hand-animate the Main Camera, you place Cinemachine cameras (lightweight "virtual cameras" that describe a shot) and let Timeline cut and blend between them.

  1. Add a Cinemachine Camera for each shot (e.g. vcam_Wide aimed at the whole room, vcam_CloseUp framing the reward). Make sure your Main Camera has a CinemachineBrain.
  2. On the timeline, add a Cinemachine Track and bind it to the Main Camera's brain.
  3. Drag each virtual camera onto the track as a clip. Order them along the ruler.
  4. Overlap two clips and Timeline automatically blends from one shot to the next over the overlap โ€” a smooth push-in instead of a hard cut (see the shaded overlap in Figure 1).
๐Ÿ’ก Cut vs. blend: no overlap = an instant cut; overlap = a blend whose length equals the overlap. Drag the clip edges to tune exactly how fast the camera moves between shots.

Signals: Running Code on Cue

Sometimes the timeline needs to talk to your game โ€” "now spawn the boss," "now re-enable input." That's a Signal: a marker on a Signal Track that fires a UnityEvent the instant the playhead crosses it, handled by a Signal Receiver component.

  1. Add a Signal Track. Right-click it at the end of the sequence โ–ธ Add Signal Emitter, and create a new Signal Asset named OnCutsceneEnd.
  2. Unity adds a Signal Receiver to the director. Wire its reaction like any UnityEvent โ€” call a method on your cutscene manager.
using UnityEngine;
using UnityEngine.Playables;

// Plays a cutscene and restores player control when it ends.
public class CutsceneManager : MonoBehaviour
{
    [SerializeField] PlayableDirector director;
    [SerializeField] MonoBehaviour playerController; // disabled during the cutscene

    public void PlayCutscene()
    {
        playerController.enabled = false;
        director.stopped += OnDirectorStopped; // fires when the timeline finishes
        director.Play();
    }

    // Called by the OnCutsceneEnd Signal (wire this in the Signal Receiver).
    public void OnCutsceneEnd()
    {
        Debug.Log("Cutscene beat reached: revealing reward.");
    }

    void OnDirectorStopped(PlayableDirector d)
    {
        director.stopped -= OnDirectorStopped;
        playerController.enabled = true; // hand control back to the player
    }
}

โš ๏ธ Always hand control back

Disable the player controller (and maybe the gameplay HUD) when the cutscene starts, and re-enable it when the director stops. Forgetting the re-enable is the classic "why can't I move after the cutscene?" bug. Subscribing to director.stopped is the reliable place to do it.

Triggering It from Gameplay

Turn Play On Awake OFF on the PlayableDirector so the cutscene waits for a cue. Then trigger PlayCutscene() from whatever gameplay moment you like โ€” walking into a trigger volume, defeating the last enemy, or pressing a switch:

flowchart LR A["Player enters
trigger volume"] --> B["CutsceneManager
.PlayCutscene()"] B --> C["Disable player
control"] B --> D["director.Play()"] D --> E["Timeline runs:
camera blend + door + music"] E --> F["Signal:
OnCutsceneEnd"] E --> G["director.stopped"] G --> H["Re-enable
player control"]

Figure 2: The cutscene lifecycle, from trigger to handing control back.

Mini-Project: The Reveal

๐Ÿ—๏ธ Build a triggered "reward reveal" cutscene

Goal: when the player steps onto a plate, the camera pushes in on a treasure, a lid animates open, a particle burst fires, and music stings โ€” then control returns.

  1. Set up the scene: a treasure object with a lid child, a vcam_Wide and vcam_CloseUp, and a trigger volume on a floor plate.
  2. Create a Timeline on a CutsceneDirector (Play On Awake OFF).
  3. Add a Cinemachine Track: vcam_Wide then vcam_CloseUp, overlapping to blend the push-in.
  4. Add an Animation Track bound to the lid; record or drop a Lid_Open clip timed to the close-up.
  5. Add an Activation Track for a sparkle Particle System so it only plays at the reveal beat.
  6. Add an Audio Track with a short music sting.
  7. Add a Signal at the end wired to CutsceneManager.OnCutsceneEnd().
  8. From the trigger volume, call PlayCutscene(); confirm control returns when it finishes.
๐Ÿ’ก Hint: the camera doesn't move / it hard-cuts

Check the Main Camera has a CinemachineBrain and the Cinemachine Track is bound to it. For a smooth push-in rather than a cut, the two vcam clips must overlap on the track โ€” the overlap length is the blend time.

โœ… Success check

Stepping on the plate plays the whole sequence in sync โ€” blend, lid, sparkle, sting โ€” the signal logs at the reveal, and you can move again the instant it ends.

๐ŸŽฏ Quick Quiz

Question 1: What actually plays a Timeline asset in a scene?

Question 2: How do you get a smooth blend between two Cinemachine shots instead of a hard cut?

Question 3: What is a Signal used for?

Summary

๐ŸŽ‰ Key Takeaways

  • Timeline sequences many things on one clock; a PlayableDirector plays it and binds tracks to scene objects.
  • Core tracks: Animation, Activation, Audio, Cinemachine, and Signal.
  • Cinemachine clips cut with no overlap and blend when they overlap.
  • Signals run code on cue; subscribe to director.stopped to restore player control.
  • Turn off Play On Awake and trigger cutscenes from gameplay.

๐Ÿš€ What's Next?

That wraps the Graphics tracks โ€” lighting, shaders, VFX, and cinematics. Next we switch dimensions entirely. Module 10: 2D Essentials starts the 2D track: sprites, sorting, tilemaps, and 2D physics, beginning with Lesson 10.1: The 2D Setup โ€” Sprites & Sorting.

๐ŸŽฌ That's a wrap on cinematics

You can now choreograph a scripted moment โ€” camera, animation, audio, and code โ€” and fire it on cue. That's the difference between a demo and a game with production polish.