Introduction to Unity Timeline

Games often use cutscenes to engage the player and tell parts of the story. The Unity Timeline allows you to harness your in-engine assets to create highly customized cutscenes. By Anthony Uccello.

Leave a rating/review
Download materials
Save for later
Share
You are currently viewing page 3 of 3 of this article. Click here to view the first page.

Approaching the Treasure

Select the Timeline GameObject and set the frame to 216. Click the Record button on the Hero track to begin recording.

Select the Hero GameObject and beneath Transform in the Inspector, set the X Position to -1 then back to 0 to set its starting position keyframe. Then, on the Timeline, set the Hero track to frame 361.

Return to the Hero GameObject and, beneath Transform in the Inspector, set the X Position to -6. Return to the Hero Track and end recording.

Finally, add a Walk Animation to the Model using the same steps as above, and extend it to frame 361:

You might notice that it looks as though the hero has walked past the treasure, but this seems to be an issue with the Timeline preview because, as you will see shortly, the hero will walk right up to the treasure and stop.

Rather than just have the hero walk with Camera2 hogging all the action, you can now use Camera3 to do a behind-the-hero shot.

To do this, beneath the Main menu in the Hierarchy window, select and drag Camera3 over the Model GameObject, which is beneath the Hero GameObject, to set it as a child.

Set Camera3‘s position to (X:0, Y:2.06, Z:-2.5). Set it’s Rotation to (X:0, Y:0, Z:0). Your hierarchy should look like the following:

With Camera3 childed to the GameObject Model, it will now follow along all the GameObject Model’s movement from behind. However, Camera3 still needs an activation track so that it is active at the right time.

As you did with Camera1 and Camera2, drag the Camera3 GameObject onto the Timeline and select Activation Track. Set Camera3‘s start frame to Camera2’s end frame, and set Camera3‘s end frame to 361:

Now, save the scene, press Play and see how things play out:

Almost there! Now, the hero just needs to open the treasure by… kicking it, of course!

Opening the Treasure

For the final shot, you will use Camera4, setting it up as you did Camera1 and Camera2.

Drag Camera4 on to the Timeline and add an Activation Track. Set Camera4‘s beginning frame to the end of Camera3’s Active phase, and extend it to frame 555. It should look like this:

Add the Kick Animation. Right-click (Command-click on a Mac) the Model track. Select Add Animation From Clip and select Kick. Don’t edit it’s duration. Your Model track should now look like this:

The treasure chest needs to open, so you’ll now add the animation for the lid of the chest. Setting this animation follows similar steps as the previous ones.

Expand the ChestBottom GameObject in the Hierarchy window. Drag the ChestLid GameObject onto the Timeline and select Animation Track. In the Timeline, set the frame to 389. Now, select the ChestLid track. Click the Record button.

Now that you’re recording, select the ChestLid GameObject in the Hierarchy window and set its X Position to -1, then back to 0 to set its initial position. In the Timeline window, set the frame to 555. Finally, beneath Transform in the Inspector, set the ChestLid Y Position to 6. Press the Record button again on the track to stop recording.

This will animate the chest’s lid to fly through the wall.

Now, it’s time to position Camera4 so that it’s over the chest when the lid flies up. Again, you’ll follow the same steps as the previous camera, so see if you can do it without every step laid out.

Set the Position of Camera4 to (X:-9.00, Y:5.4, Z:5.18). Set Camera4’s Rotation to (X:90, Y:0, Z:0).

As with the other added cameras, adding an animation will make the scene more exciting, and it will look good to zoom in as the chest is opened.

Select the Timeline window. Drag the Camera4 GameObject onto it and create an Animation Track. Set the track to frame 389. Click the Camera4 track and then click the Record button. Select the Camera4 GameObject. Beneath Transform in the Inspector, set the X Position to 0, then back to -9.

In the Timeline window, drag the Animation Track to frame 555.

Finally, set Camera4‘s Y Position to 3.74:

The full scene is now done. Press Play and have a look!

Managing Complexity: Grouping Tracks

This was a short animation with only a few actors, so it’s pretty easy to keep track of the GameObjects and various Tracks. But creating a more complex scene with many moving parts and actors can become very difficult to manage. This is why organization is absolutely critical. While your scene may look done (and it is, great job!), it’s a good idea to take a few minutes and organize it — your future self will always thank you for this.

One way to organize your work is to group tracks. First, Right-click (Command-click on a Mac) under the tracks in the Timeline window and select Track Group. Click on Track Group and, in the Inspector, set the name to Activations:

Repeat this process to create a Track Group called Animations. Your Timeline should now look like this:

Now, drag and drop all of the tracks with Active sections into the Activations Group and all the others into the Animations Group. You can then open and close each group to allow for much easier readability and editing as needed:

Remember to save your work. Lean back in that director’s chair and give yourself a pat on the back! You have completed your first Timeline.

Where to Go From Here

If you skipped through some parts of this tutorial, don’t forget you can download both the starter and final projects using the “Download Materials” link at the top or bottom of this tutorial.

You’ve done great work and created a cutscene using model animation, camera changes and object lifecycle updates — yet there is still so much more to explore. One of the biggest things related to Timelines is custom scripting, wherein you tie in special animations with code that you want to execute along with it. You can learn more about custom scripts here. If you’re feeling bold, why not try adding a custom script to this scene after the treasure is opened?

If you are interested in learning more about Unity animations in general, be sure to check out this great Introduction to Unity Animation.

To learn more about creating 3D models and the Animation window, check out this massive series by Unity here.

Last but not least, if you are interested in making games, you should consider getting our Unity Games By Tutorial book. It covers how to make four types of games from scratch and walks you through every step of the process.

Be sure to post any questions you have below and feel free to join us in the forums.