Handle animations with Timeline | Unity
A very quick guide about how to handle animations using the timeline in Unity
Objective: Handle the animations of a cutscene using the Timeline in Unity.
In the last post I covered how to use a dolly track in Unity to build a cutscene. Now, it’s time to find out how to handle the animations of a cutscene inside the Timeline with Unity.
We have the next previs element to take it as a reference to compose the cutscene:
This cutscene is expected to be shown when the player completes the level and it basically displays a thief (the player) grabbing a door knob to open the main vault of a building with jewelry. Let’s move the camera and put the respective model to define the shot of our cutscene:
Once we have the model in the desired position, let’s open the Timeline window by clicking on Window > Sequencing > Timeline:
If we select the model of the cutscene in the Hierarchy we’ll see that there’s an Animator component attached already. This Animator component uses an animation controller to handle the animation clips that the model displays.
Now, in order to be able to use the Timeline for our cutscene, let’s select the empty gameobject that is parent of the model. Once selected, let’s click in the button at the Timeline window to create a new timeline playable asset for the cutscene:
Handling the animations
The Timeline will allow us to control the animations of our model and synchronize them with different aspects that compose the cutscene like the audio and the cameras. In order to handle the animations of our model, let’s drag the gameobject that contains the Animator component into the Timeline and choose to add a new Animation track. Once we add it, let’s right-click in the timeline and choose Add From Animation Clip to select the animation clip that we want to handle:
And now, by having the animation track in our Timeline, we’re able to handle the animation and synchronize it with another essential elements for our cutscene like audio and cameras. We are able to display the animation without having to play the scene, we can just drag the white arrow in the Timeline to see the state in every frame or second:
And that’s it, we can handle animations for our cutscene in Unity! :D. I’ll see you in the next post, where I’ll be showing how to synchronize the audio and the visuals to build a cutscene in Unity.