Introduction to Timeline in Unity
The Timeline feature in Unity is a powerful way to create cinematic cutscenes, while being able to interact with virtual cameras, animations and game objects.
To get started, go to Window, and then scroll down to Timeline.
After timeline has been opened, I select the Sleeping_Guard_Cutscene game object, and then get a notification in the Timeline that I will need a Director Component and a Timeline asset.
After pressing the Create button, I am prompted to save into a file location on my computer. I navigate to my game folder and create a new folder called Timeline.
I click into the timeline folder and choose it as my save location, by pressing the save button.
Back in Unity, I move the Timeline below my game and scene views, and delete the auto-generated clip.
With the Sleeping Guard Cutscene game object selected, I can now see the Playable Director component in the inspector, which was created automatically when I pressed the create button in the timeline. Play on Awake is checked, which means this cutscene will play as soon as it is active.
If you select the main camera, you can now see a Cinemachine Brain component has been added. Cinemachine is a powerful add-on found in Unity’s Package Manager, that enables let’s us use multiple virtual cameras to create complex cut scenes, as well as many other camera needs being simplified for the developer.
The first thing I need is a Cinemachine Track, to control changing between the virtual cameras. The easiest way to do this is to drag the main camera with the cinemachine brain on it, into the timeline, and then select the Cinemachine Track option.
A numerical reference now appears in the timeline showing frames as the default way to progress into time. You can right click the small gear icon to change this to seconds. Using seconds over frames is much clearer regarding how long the cutscenes are while arranging them.
Before adding the virtual camera to the timeline, I need to right-click in the timeline and add a Cinemachine Shot Clip.
Selecting the Cinemachine Shot clip will show some added information in the inspector. Down in Cinemachine Shot, it is looking for a virtual camera to assign.
I can now drag my first virtual camera for the rear view into the slot on the Shot Clip to assign it.
I create another clip in the timeline and add my front view camera.
Both clips are side by side in the timeline.
Dragging the arrow to preview the cutscene shows how the virtual cameras change as I scroll through the timeline.
As an alternate to the hard camera cut above, you can drag one cut over the other to create a blend transition from one camera to the other.
Here is how that looks. I am going to use the hard cut for this cutscene, but the transition does open some nice camera options to keep in mind for situational usage.
The actors in the scene have an animation that plays when the game is being played, but it’s not currently playing while I am making the cutscenes. This is important when it comes to making the scene, so let’s add in the animation so I can work with it live. To do this, press the Add button and add an Animation Track.
Now I can drag the Sleeping Guard Cutscene game object into the animation track to assign it.
I still need to add the animation that is playing. To do that, click the little three stripes drop-down and select Add Animation from Clip. This will open a window with all game animations, and you can select the one you want.
For this scene, I choose the Get Card Animation, and it now appears in the timeline.
Now when previewing the cutscene, the animation will play.
I hope you enjoyed this voyage into timeline in Unity! In my next article, I will finish up the cutscene and showcase more of what timeline can do. Thanks for reading!