Control Tracks and Nested Timelines
--
A Control Track in Unity Timeline enables you to control time-related elements and Playable Directors in a GameObject
This means that you can have multiple Timeline Assets with their own individual Playable Director components in the same sequence. It sounds a little confusing at first, but no worries, we’ll take a look at this step by step.
Objective: Learn how to add multiple timelines into one timeline sequence and understand why this could be useful.
Table of Contents
· Creating your Timelines and Playable Directors
· Using a Control Track to Nest Timelines
∘ Why is this useful?
· The Result
Creating your Timelines and Playable Directors
- The first step is to create more than one Timeline and Playable Director per object.
Let’s start with an Empty Game Object — we always store our Timeline Asset and Playable Director Component in an Empty Game Object as best practice. Since we’ll have multiple directors/Timelines, you need to give them unique names to identify them easily.
You can name this after the Director or the Timeline, it doesn’t matter since both will exist in the same object, the idea is to know what this empty game object is controlling, and using both words as identifiers would just be unnecessarily long.
2. Make the desired object into a Child of your Empty Game Object Director. Whichever object goes in here will be controlled by this Timeline and Director.
3. Creat a Director Component, this should be stored in a Director folder in your Project assets, if you don’t have one already go ahead and create it as well.
4. Create an animation sequence for your Timeline. You can check out how to do this here.
You can repeat this process for every Timeline you want to create.
Using a Control Track to Nest Timelines
In this example, I have an animation that plays in my Sphere_Timeline, and I want a second animation to play once the sphere animation is done. The issue is that the other animation belongs to a whole different Timeline, this is where Control Tracks come in.
- Adding a Control Track is as simple as dragging and dropping your Timeline object, Unity will automatically recognize it as a Control Track.
2. You can position your Control Track so that it plays at any given point in your Timeline, I set up mine to play after the sphere sequence.
Why is this useful?
When working on a game you are likely to have multiple objects with dedicated animations and behaviors. Whenever you want to mix and match these animations into one cohesive sequence, this simplifies the entire process.
The Result
Here we have our first Timeline, Sphere_Timeline, playing a sequence. Then the control track initiates the Timeline sequence from the Cube_Timeline object.