Signal Emitter to Alter Timeline Playback

addam davis
3 min readFeb 23, 2024

--

Objective: Manipulate the Timeline with Signal Emitters!

Not only can we use signal emitters to talk to scripts and call functions we can also use them to alter our playback. In order to do this, we need to create a script. We are going to need to access the director, the timeline specifically and adjust the playback.

In the script we need to add the library UnityEngine.Playables.

Go ahead and attach this script to the director.

Now we want to create a public function to pause the Timeline.

We are also going to need a reference to the playable director so in start we need to do a get component to set the playable director to a variable.

In our pause method we can now call on the director variable and call the pause method.

On the Timeline we can now add a signal emitter. Create a new signal, call it whatever makes since to you. When we his this signal we want to call the pause method.

If you play the editor you will see the timeline play up to where it hits the signal emitter and then it pauses.

Now how do we, with code, get the Timeline to start again? We can create a new function that allows up to play.

In the update we can create a check for the space key, when that is pressed call the play function.

What if we want to skip ahead? Let’s say we want to skip a few seconds ahead in the Timeline. We can create a float variable. Serialize the variable and in the inspector set the amount of time you want to skip to.

Instead of having the director play in the update method we can skip ahead first then play.

Now play the editor and you will see the timeline skips ahead to the time you selected.

Now you see how we can use scripts to make the Timeline play the way that we want it to. Don’t be afraid to experiment with your Timeline and I’ll see you in the next tutorial!

--

--