After you make your cinematic with Unity, Cinemachine, and the Timeline editor, you are probably wondering about how you want to trigger these cutscenes.
[Side Note]
At the time of writing this, Unity doesn’t allow you to use Cinemachine’s “Activation Track” to deactivate the game object that contains the “Playable Director” component. However, you CAN deactivate the parent object of the “Playable Director”!
If you make sure that the “Play On Awake” box is ticked within your cutscenes “Playable Director” then your cutscene will play as soon as it is set as active.
This means all you have to do is make a reference in a script to the _cutscene game object and then use the line of code… “gameObject.SetActive(true);”
You can do this via a triggered collision as seen in the example above, or from a button that calls to a specific method within your script.
You can deactivate your cutscene after you finish playing it through various means. You could hard code it to deactivate after a certain number of seconds using a “Coroutine”. Or you could set booleans within your script to determine that when the “Player” game object touches the trigger initially it activates the cutscene and deactivates the player, but then when the cutscene ends you could use the activation track to bring the player back. When that then retriggers the collider which would otherwise replay the animation, you would use the boolean parameter to then determine that if it is ticked then it will instead deactivate the cutscene trigger.
For today’s article though, we will be using “Timeline’s” “Activation Track” to deactivate the parent game object that is holding our cutscene after the cinematic is done playing.
After you reference the activation track’s parent object, stretch the “Activation Clip” to about 1 frame short of the end of your cinematic.