Timeline in Unity
In this article we will use the Timeline of Unity to continue working on our cutscene.
What is the Timeline in Unity
The Timeline in Unity is way to visually edit a sequence of events along the time axis. Events can be music, play animation, particles, enable or disable objects, move objects around etc etc.
Create a new Timeline
Select the cutscene gameobject that contains our virtual camera’s and actors.
Window > Timeline (panel) > click Create (button)
It is recommended to create a separate folder to save our timelines in. When it is created it should look something like the image below.
On our Cutscene gameobject we remove the Animator component. We only need the Playable Director component here, since we aren’t animating our Cutscene gameobject itself. So also remove it from the timeline.
Playable director decides when our cutscene gameobject is enabled and plays. We can do this through code and let it play the timeline asset.
To use the cinemachine virtual camera’s in our timeline we need to add the main camera.
Timeline (panel) > Add > Cinemachine.Timeline > Cinemachine Track > Select Main Camera for the Cinemachine Brain
Timeline Settings to Seconds
Timeline (panel) > Gear icon (top right) > Seconds
Use Virtual Camera’s from Timeline
Now we are ready to use our virtual camera’s from our timeline.
R-Click in Timeline > Add Cimemachine Shot Clip
Inspector > Virtual Camera > Drag in our Virtual Camera
Repeat these two steps for our second virtual camera.
Adjust Duration of a Clip by simply dragging
Preview Timeline
With the Play button we can get a preview of our Timeline.
Bonus: Blend shots
Currently it’s a hard cut from shot to shot. It’s also possible to blend.
Drag one shot into the other. You can adjust the duration with it too.
Let’s preview the blend.