Timeline: Introduction and Creating Simple Animations
In this article, we will cover getting started with Timeline and create a simple animation. According to Unity’s documentation, you will “…use the Timeline to create cut-scenes, cinematics, and game-play sequences by visually arranging tracks and clips linked to GameObjects in your Scene.
We will need to add the Timeline Window to the editor.
With the Timeline window open, select the game object in the hierarchy you will want to animate and create a Director Component and Timeline asset.
Now, we have a Timeline for the game object we selected.
Playable Director Component
Looking at the game object, there is now a Playable Director component added to it. The Playable Director is the component that plays the Timeline animations.
It has a few settings starting with Update Method…
DSP — plays the Timeline according to the speed of an audio track.
Game Time — plays the Timeline according to the game’s speed. If the game is running at half speed for a slow motion effect, so will the animation.
Unscaled Game Time — plays the Timeline at a speed that is not affected by the game time, so if the game is playing in slow motion the animation will be playing at normal speed.
Play On Awake controls if the Timeline will play as soon is the game object is activated.
Wrap Mode will either have the Timeline loop or hold on the last frame.
Lastly, Initial Time will be the amount of time that will pass before the Timeline plays.
Creating A Simple Timeline Animation
We are going to add an Animation Track to the Timeline of the coin game object.
You will need to make sure to create an Animator for the game object, so an Animation can be created and added to it.
Click on the Record button to enter Record Mode and you will see the Timeline turn red.
While in Record Mode, left-click on the game object and add a key frame.
We are going to add one more key frames by moving the time slide to the desired end time and rotating the game object 360°.
When the Timeline is played back, the coin rotates 360° from the first key frame to the last key frame in 2 seconds.
In the Animation window, you can adjust the timing of each individual key frame or all of them.
You can also adjust the speed of the animation by right-clicking on the Timeline and converting the animation into a Clip Track. This allows you to use the Speed Multiplier to either slow down or speed up the playback of the timeline.
You can adjust the Ease In and Ease Out by holding Control (PC) or Command (Mac) and dragging/holding the clip ends.
You can record multiple animations on the timeline and have them blended, moved on the timeline and deleted.
If you want to stack animation movements, you can do that in the Animation window and simply enter record mode and start adding addition movements.
Above you can see how the Coin object is rotating and moving up and down at the same time.