CTIN 289 - Interactive Snippets Library

Powered by 🌱Roam Garden

Unity Timeline for Cutscenes


You can use Unity’s timeline editor to make cutscenes.

Start by adding a Playable Director to an empty game object.

Next, reference that playable director in code. You can also set time to 0 on awake to be safe and ensure the time is reset to the start.

public PlayableDirector openingCutscene;

private void Awake()

    {

        openingCutscene.time = 0;

    }

You can add a boolean such as cutscenePlayed to track if the cutscene has already played and use this to prevent the cutscene from playing again if you don’t want it to.

// once cutscene is playing, set bool to true

        if (openingCutscene.state == PlayState.Playing)

        {

            cutscenePlayed = true;

        }

Now, you can either set the cutscene to play on awake if it is to play at the start of the scene, or you can trigger it to play through code with this:

doorOpenCutscene.Play();

You can use bools to set when cutscenes are triggered.