Cinematography in Unity — Introduction to Timeline
Using Unity’s Timeline feature to sequence events

We continue our studies of cinematography in Unity by introducing the Timeline feature in Unity. What do I mean by cinematography in Unity? By that I mean the intelligent use of Unity cameras and visual tricks to make the best looking games we can.
What is Timeline?
Timeline is a Unity package and utility designed for creating cinematic content and event sequences. It allows us to easily coordinate the activities of different objects over a specified quantity of time.
Timeline is a product of Unity and free to all Unity users. It can be installed through the Unity package manager, which can be accessed through the Window menu.
Getting started with Timeline
The first thing we need to do to use Timeline (after installing it, of course) is to add the Timeline window to our Unity editor. This can be done by finding it in the Window menu under Sequencing.
Once we have it in the editor we can move it around the same as any other window. I would personally recommend you keep the Timeline window separate from the Scene and Game windows, because we will want to be able to see things happening in our Scene and Game windows as we make use of Timeline.
Next, we should be able to see in the Timeline window whether any game object we happen to be inspecting has a timeline attached to it. Or, more accurately, whether it contains the Playable Director component, and if this component has a Playable asset assigned to it.
If not, we are provided the option to Create a timeline. This will automatically fulfill the requirements listed above — the object will receive a Playable Director component, a new Playable asset will be generated, and this Playable will be assigned to this object.
A good practice to follow is to put timelines on empty objects that contain everything the timeline is going to involve. For instance, if you were attempting to create a cutscene, you may wish to organize the cutscene by having an object contain all of the models, cameras, and UI elements that the cutscene involves, and then put the timeline itself on this organizing object.
Starting out with tracks
The main thing we work with in timelines are called tracks. Tracks are all of the individual sequences of events or actions that might go into a timeline. For instance, you may be creating a cutscene where one track handles the animation of a model, another handles the audio being played, and one more controls the movements of a camera.
Let’s take a look at a very simple example. I have a timeline with just a single track — an activation track. This track just does one thing, and that is it determines whether or not the object attached to it is active at that moment.

This is done by using the Add dropdown button in the Timeline window, and then adding an Activation Track. Once the track has been added, associate the object you want control over with that track. Then you can add individual Activation Clips to the track using the interface.
Any times during this timeline where the track shows as “Active”, the object will be active. All times where it is not “Active”, the object will not be active. An active object means it is visible and affecting the scene.
So, in this example, I have placed a simple sphere into the timeline, and it is active for a 1/2 second, inactive for a second, and then active again for a 1/2 second. Let’s see the result.

A simple example, but I think it illustrates the capabilities of Timeline.
Working with Cinemachine and Timeline
Seeing as we just took our first look at Cinemachine in the last article, I only think it fitting that we take a look at how these two packages can work together.
The first thing we need to work with Cinemachine is to add a Cinemachine Track. What this track is looking for, however, is something we did not cover in our exploration of Cinemachine. What the track is looking for is an object with the Cinemachine Brain component. What this component does is not important right now, but where it is by default is on the Main Camera object.

Now that we have the Cinemachine Track, what we can do is determine which Cinemachine camera footage should be used at what time.
I have a created an example where I have two Cinemachine cameras pointed at the same sphere object, but from different angles. All I need to do in Timeline is drag the cameras onto the track and then use the interface to configure which camera is in use when. Here it is in action.

It’s as easy as that, but actually it can be even better.
Just by simply using the interface to have the two camera schedules “overlap” on the track, Unity automatically creates a very cool transition effect. Take a look.

No extra coding, no special work, all done out of the box.
Conclusion
After working with it for just a little awhile, I think it’s clear that Timeline can be a very powerful tool for creating sequenced events in our Unity projects. I am very excited to be able to take advantage of these time saving utilities in my own games!
In the next article, we’re going to expand on our Cinemachine and Timeline skills by learning about Dolly Tracks. Until then, thanks for reading.