Introduction to Timeline

Unity defines Timeline as a component to be used with the purpose of: “ create cinematic content, game-play sequences, audio sequences, and complex particle effects”. In a way, a timeline is just an animation track with a number of events. Timeline is integrated to Unity by default. In this article, I will focus on using Timeline in a cutscene.

While preparing the scene, we can easily manipulate the camera view, the game objects, the audio or any other thing in our scene by using Timeline.

To open up the Timeline Windows, you can simply click Window — Sequencing — Timeline (for Unity 2020). If you are using an older Unity version, you might see Timeline directly under Window.

It is recommended to place the Timeline window just below the game view so that we can work more efficiently. Once you open up the Timeline window, it will ask you to select a gameobject to start creating a timeline.

We have two virtual cameras on this scene, and Timeline will be the tool that I am going to use in order to switch between the cameras during the cutscene.

To create a Timeline, we simply select the game object that we want to build the timeline on, and then select create.

You will observe that “Playable Director” component will be added to the game object. Playable object is automatically set to the timeline we have created.

Playable Director Component in the Inspector

In order to start animating in between the cameras, we need to find a way to introduce the Cinemachine Brain to the Timeline. As we know, Cinemachine Brain component is automatically added to Main Camera once we create a virtual camera. Just click the + button on the leftside and select Cinemachine Timeline — Cinemactine Track or just drag and drop the Main Camera game object on the Timeline and select Add Cinemachine Track.

Now, our Timeline has an idea about the Cinemachine brain on our scene. First, to make the Timeline field seconds dependent rather than frame dependent, we simply click on the gear on the right and select “Seconds”.

Now that our timeline is seconds dependent, we can add our Cinemachine shot by simply right clicking and selecting “Add Cinemachine Shot”.

As we have added the shot, you will notice that it will ask for a virtual camera on the Inspector.

Since I want to use 2 virtual cameras, that will be switching within this scene, I simply drag and drop the first camera to this field. Just by clicking next to the end of the first shot, we can simply add a new Cinemachine Shot. For the second shot, I have chosen the second virtual camera and arranged the seconds according to my desire.

Even by now, we can observe that camera is being changed on the preview if we click hit play on the timeline. You will notice that the switch between the cameras is sharp and direct.

I am actually surprised to findout that Unity Timeline has such an easy blending feature. Simply by dragging the second shot onto the first, we can create a blend effect, which will result in a softer switch to the second camera.

Adding The Animation to The Timeline

As you can see above, the animation does not play yet. In order to have more control for making the last touches on this, it’s better to add the animation clip and arrange the virtual cameras according to our desire by looking to it.

Right Click on the Timeline and click on “Add Animation Track”. Just drag and drop the game object that we have the animator on. Then, select the animation that you want to be played and you are done.

Unity Developer