๐ฌ 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
- Install Timeline and Cinemachine from the Package Manager if they aren't already (Cinemachine is what we'll use for cameras).
- Create an empty GameObject named
CutsceneDirector. - Open Window โธ Sequencing โธ Timeline. With
CutsceneDirectorselected, click Create โ Unity adds a PlayableDirector and saves a new.playableTimeline asset (put it in anAssets/Cutscenesfolder). - 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 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.
- Add a Cinemachine Camera for each shot (e.g.
vcam_Wideaimed at the whole room,vcam_CloseUpframing the reward). Make sure your Main Camera has a CinemachineBrain. - On the timeline, add a Cinemachine Track and bind it to the Main Camera's brain.
- Drag each virtual camera onto the track as a clip. Order them along the ruler.
- 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.
- Add a Signal Track. Right-click it at the end of the sequence โธ Add Signal Emitter, and create a new Signal Asset named
OnCutsceneEnd. - 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:
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.
- Set up the scene: a treasure object with a lid child, a
vcam_Wideandvcam_CloseUp, and a trigger volume on a floor plate. - Create a Timeline on a
CutsceneDirector(Play On Awake OFF). - Add a Cinemachine Track:
vcam_Widethenvcam_CloseUp, overlapping to blend the push-in. - Add an Animation Track bound to the lid; record or drop a
Lid_Openclip timed to the close-up. - Add an Activation Track for a sparkle Particle System so it only plays at the reveal beat.
- Add an Audio Track with a short music sting.
- Add a Signal at the end wired to
CutsceneManager.OnCutsceneEnd(). - 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.stoppedto 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.