How to Trigger your Timeline Using Player Input!

3 min readFeb 17, 2025

Objective: Create a simple script that allows your player to interact with the Playable Director!

If you have followed along with my articles and tutorials, we have created multiple Timeline directors that either start on awake, or are controlled by another director. Now, we are going to be controlling the director’s start time with player’s input.

In my scene I have created a treasure chest animation with particle effects and sound effects.

To follow this tutorial you can use whatever director you have, it makes no difference. As long as you are using a director you want to be interacted with this will be fine. With your director in place, we need to make a trigger. I used a cube, and made it stretch out in front for the player to walk into.

Next turn off the mesh renderer and set it to is trigger.

We are now ready to write some code. Create a script and place it onto the trigger, (the cube we just created.) To begin, we need access to the playables library.

Continuing from here, I used two variables. A playable director, and a bool.

I’m using the bool to limit when the player’s imput is valid. I don’t want the player to be across the map and press the E key and the treasure still open. We need an ‘On Trigger Enter’ and ‘On Trigger Exit’ method. On the enter method we want the bool to be true, and on the exit the bool should be false.

Since we are using input, we need to add a check for input in the update method. When the input happens, we want to play the director.

In the editor you need to assign the playable director, select your timeline object in the hierarchy and drag it into the inspector.

Play the editor and your timeline will now begin when the player is in the trigger and presses the assigned key.

--

--

No responses yet