Nerd For Tech
Published in

Nerd For Tech

Tip of the Day: Using Timeline Signals to Skip any Cutscene in Unity

If you have used cutscenes in Unity then you have probably deactivated some playable assets during the cutscenes and activated them again right before ending the cutscene. But skipping it abruptly might not reactivate your playable assets again.
Skipping the cutscene can be done using a gameManager that can hold the playable director of that specific cutscene, which is not very modular and cannot be used with many cutscenes.

How can we solve these two issues?

Deactivating and reactivating playable assets

The simplest way to do this is thru timeline directly. Simply add an activation track, add the playable asset to it, and then adjust the Active track to only be active at the last frame of the timeline.

You can set the duration of the active track to one frame and adjust it to be active in the last frame of the cutscene.

Modular way to skip a cutscene and reactivating the playable assets

We are going to use two things:

  1. A game manager to control player input during cutscene to skip it. So create a GameManager script and attach it to a Game Manager gameObject.
  2. Timeline Signal Emitters: These are quite interesting, and they are basically an event that need an emitter, an asset, and a receiver.

In the GameManager script, we want to a PlayableDirector to track the current timeline being played, and a bool to know if the bool has been skipped to prevent the player from keep pressing to skip. Also lets create a float to determine to when we need to skip the scene to. (Just follow along)

private PlayableDirector _currentDirector;
private bool _sceneSkipped = true;
private float _timeToSkipTo;

Now we create a public method that we will use with the signal emitter (event) to get the timeline we need to skip and to set the _sceneSkipped bool to false in order to allow the player to skip scene. Also create another public method to that will assign the skipping time float we create above.

public void GetDirector(PlayableDirector director)
{
_sceneSkipped = false;
_currentDirector = director;
}
public void GetSkipTime(float skipTime)
{
_timeToSkipTo = skipTime;
}

Let’s now set the signal emitter in the timeline.

As you can see in the above, in the Timeline, right click on the Markers tab, right click, and add a signal emitter. Set time when you want the signal to be emitted.

Select the created signal, and in the Emit Signal, you can create a new signal asset, this will allow you to set a signal receiver.

After creating the asset, just like any other unity event, drag the GameManager gameObject to the emitter, and choose the cutscene for the parameter. In the script this will us to set which scene we need to skip, also specify the time to skip to.

Now in the update of the GameManager script, check for player input, and then change the time of the timeline to right before activating the playable assets.

Here is what the final code and timeline skip will look like.

Skip any scene and prevent the player from continually pressing the skip button
After the signal the player pressed the skip button and the timeline skipped to the specified time.

Using this method will allow you to add a signal emitter to any scene you want to skip and will give your timeline a little time to reactive your playable assets.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store