Introduction — Timeline in Unity

Samarth Dhroov
Aug 10 · 4 min read

This article explores one of the most powerful tools in Unity called as Timeline.

To begin with, one must understand the need of timeline when the option of animation is already available.

  • An animation is basically a clip that represents a state of a game object such as running, idle, walking, etc. The animator takes the seat of a controller that dynamically switches the states of a game object that it is attached with, based on predetermined conditions/rules.

So, It can be inferred that animation-animator combination is restricted to changing states of a game object.

But what if you wanted to impact several objects in a linear sequence at different moments? That problem gets solved by timeline :)

An official Unity definition is as followed.

The Unity Timeline Editor is a built-in tool that allows you to create and edit cinematic content, gameplay sequences, audio sequences, and complex particle effects. You can move clips around the Timeline, change when they start, and decide how they should blend and behave with other clips on the track.

How does it work? It takes two elements.

A timeline asset and a playable director. These components resemble the relationship of an animation-animator. They both work the same way :)

  • A Timeline Asset is any media (tracks, clips, recorded animations) that can be used in your project. It could be an outside file or an image. It could also be assets created in Unity, such as an Animator Controller Asset or an Audio Mixer Asset.
  • A playable director connects this asset to a game object resulting in a timeline instance.

Below is how you get access to timeline.

Unity
Unity

Next comes the “+” option which has a drop down menu of 6 track items. (It would be 7 if cinemachine is installed.)

So, what is a track?

A track is an action(clip) that applies to a specific game object. Each track facilitates different type of action(clips).

“ONE TRACK CAN ONLY CONTROL ONE OBJECT.”

A general menu description is as followed for these tracks.

Unity

Please keep in mind that each of these tracks is a subject matter in its own(Although there is a good overlap among them) and hence, this article does not address every track.

Below is a very simple use case of activation track in timeline.

As seen above, the camera2 remains inactive until the timeline hits the activation action. On the other hand, the camera1 goes inactive at the same time. To accommodate this, surprisingly, you did not have to code it :)

Unity

To complete the circle, you must see the playable director component on this game object.

Unity

Now, to build upon the lesson so far, assume that if the task is to play different sound when camera 2 goes active, the audio track can come into play and accommodate it.

All you need is one another empty game object with an audio source component. The audio files however, would be mentioned in the track and not in the audio source component.

Let us see one more track for animation.

As explained in the initial section of this article, animation is a play of state changes based on rules/conditions.

But what if you just wanted to animate something while something else is happening. In this example, as the cameras are swapping, how about making some movement on ground.

In typical scenario, I would probably look out for some sort of input to trigger an animation of movement. However, timeline can come into picture and basically make that happen without any input.

As seen above, we can create animation as well in timeline. Obviously, external animations can be attached as well.

So, in general, timeline allows a unity developer to wear the hat of a director on a film set. You get the chance to orchestrate events that need to happen as per the requirement of the gameplay. And, all that should happen with least amount of effort.

Timeline is a massively powerful tool but for the scope of introduction, this seems a good start :)

The next article will cover cinematic cuts in a game using timeline :)

See you soon.

Thank you very much

Geek Culture

Proud to geek out. Follow to join our +1.5M monthly readers.