Timeline in Unity 2020
Timeline in Unity
Unity's Timeline Use Unity's Timeline to create cinematic content, game-play sequences, audio sequences, and complex…
“Use Unity’s Timeline to create cinematic content, game-play sequences, audio sequences, and complex particle effects.
Each cut-scene, cinematic, or game-play sequence that you create with Unity’s Timeline consists of a Timeline Asset and a Timeline instance.
The Timeline window creates and modifies Timeline Assets and Timeline instances simultaneously.”
Creating a Timeline Asset and Instance
Creating a Timeline Asset and Timeline instance
To use a Timeline Asset in your Scene, associate the Timeline Asset with a GameObject using a Playable Director…
“To use a Timeline Asset in your Scene, associate the Timeline Asset with a GameObject using a Playable Director component.
Associating a Timeline Asset with a Playable Director component creates a Timeline instance and allows you to specify which objects in the Scene are animated by the Timeline Asset.
To animate a GameObject, it must also have an Animator component.
The Timeline window automatically creates a Timeline instance while creating a new Timeline Asset.
The Timeline window also creates the necessary components.”
Playable Director Component
Playable Director component
The Playable Director component stores the link between a Timeline instance and a Timeline Asset. The Playable Director…
“The Playable Director component stores the link between a Timeline instance and a Timeline Asset.
The Playable Director component controls when the Timeline instance plays, how the Timeline instance updates its clock, and what happens when the Timeline instance finishes playing.
The Playable Director component also shows the list of tracks from the associated Timeline Asset (Playable property) that animate GameObjects in the Scene.
The link between Timeline Asset tracks and GameObjects in the Scene is referred to as binding or Track binding.”
The Timeline Playable Director settings are listed above with their descriptions for ease of reference.
Installing Timeline in Your Project
If you aren’t sure that your project has Timeline installed, click Window > Package Manager in the Unity Editor.
Scroll down to Timeline and verify there is a checkmark indicating that it is installed.
You can install or update the Timeline package as needed here.
Initial Project Setup
We just want to get a feel for Timeline right now, so we aren’t doing anything overly complicated with our initial scene setup.
I’ve created a brown plane, a blue cube, the associated materials and placed the cube above the plane slightly.
Next I select the cube, and clicked “Create” in the Timeline window to create a playable director component for animating the cube using Timeline.
Once created, I dragged “CubeTimeline_01” that was generated by Unity into the scene view resulting in what you see above.
As a cautionary side note, I installed the latested 2020.3.32 Unity and this threw errors immediately.
Downgrading the editor for this project back to 2020.3.30f1 resolved the issue.
Somebody really jumped the gun on releasing .32 it seems since adding a timeline to a cube breaks it.
Update: The next day Unity was asking me to upgrade .31, so this bug was caught pretty quick, unsurprisingly.
If we quickly browse the Timeline window’s settings, we’ll fine a setting to keep our measurement of time in either seconds or frames, I chose seconds for simplicity and ease of use.
There is also a default frame rate that can be selected, which I left at 60 fps.
Timeline Track List
Track list and Track headers
Use the Track list to add, select, duplicate, delete, lock, mute, and reorder the tracks that comprise a Timeline…
There are four kinds of tracks for the Timeline window.
These include Activation, Animation, Audio, and Signal tracks.
We can see these tracks listed when we add our cube to the Timeline window.
We’ll be animating the cube, so we select the Animation Track.
We want our cube’s starting position in the animation to be where it is presently.
If we click our cube in the hierarchy view, hover over the Transform component, and right click we’ll see a menu pop-up.
Clicking “Add Key” accomplishes our task.
Now, I want the cube’s animation to end with the cube in its exact starting position.
This animation will be 8 seconds long, so I click the 8 second mark on the timeline (in record mode), click the cube, and add another key.
I’m just going to move the cube around in a horizontal circle, and I want it to be a fairly even movement.
So, dividing our 8 seconds into 2 second slices, we click on the 2 second marker, reposition the cube, rinse and repeat for the 4 second and 6 second markers.
Sometimes things don’t go as planned so apparently my 8 second marker is incorrectly positioned.
Easy enough to fix!
Just place the timeline marker all the way at the 1st frame, 0 seconds, copy the Transform component values.
Then hit record on the timeline, click the 8 second marker that should be the same position, and copy the Transform component values in.
End recording mode.
Now, we can “scrub” through our timeline and see the cube movement is as desired as well as hitting the play button on timeline to watch it move at the proper speed.
Now, if we decide that 8 seconds is too long for this animation, we can use the Animation window to shorten the duration of the overall animation.
If we right click the selected area, we can create a “Clip Track” and modify the speed and other settings in the Inspector window.
We can add ease-in or ease-out to our animation by holding the CNTRL button on either end of our Clip Track and drag it where we please.
Now, this animation is pretty short so it is not as noticeable, but you can see the cube seems to “speed up” during its animation.
Notice that in the inspector window of our Clip Track, the Ease In duration has values to correspond with our modifications.
You could use just the inspector window to create your ease in and out values as well, but I think most will prefer dragging it on the Timeline window.
So, now that we know how to use Clip Tracks, you can start to see how this would be handy for more complex animation sequences.
With a clip track, you can move it from starting at 0 seconds to whenever it should begin, and combined with other clip tracks create a very nuanced sequence that includes movement, audio, etc.
We’ll get into a more advanced set of clip tracks in the next article!