My journey becoming a Unity game developer: Sleeping Guard Interaction-Activate sleeping guard’s cutscene

Rhett Haynes
3 min readNov 16, 2021

Objective: Activate the Sleeping Guard Cutscene when the player reaches the guard’s desk. Also, remove the real Security Guard and Player from the screen when the cutscene is playing.

Cutscene plays when player reaches the guard’s desk, then the game’s guard and player reappears to continue playing the game.

Create a new script name GrabKeycardActive which we will use to activate the Sleeping Guard Cutscene. Create a new variable Type Game Object that will hold the actual Sleeping Guard Cutscene game object itself. Then using the OnTriggerEnter() function, check IF the other object that collides with the Security Guard’s desk is the Player tag. If so, set the Sleeping Guard Cutscene to Active.

Activates cutscene when the player enters the zone.

Select the Grab Cut Scene Zone game object which has a Box Collider around the desk. Drag the GrabKeycardActive script onto it, add a Rigidbody component with Use Gravity turned off, and turn on Is Trigger for the Box Collider.

Sleeping Guard Activate script added to Grab Cutscene Zone game object with Rigidbody attached.

Click on the Sleeping Guard Cutscene game object to gain access to the Timeline editor for this cutscene. Either double-click on the Playable Director slot or select Window->Sequencing->Timeline to open the Timeline editor.

Create a new Activation Track and drag the Sleeping Guard game object into its slot. We want to make the guard disappear during the cutscene playing and bring him back at the last frame before the cutscene ends. Either drag the track from the beginning to the last frame or click on the track, and in the Inspector change the Duration to be separated by one frame, then in the Start setting set the value to be one number in front of the End setting frame value.

Activation track used to have the sleeping guard game object reappear at the last frame of the animation.

Create another new Activation Track and drag the Actors game object inside of the Sleeping Guard Cutscene object which will show the actors from the cutscene in the Scene View. This time we want the Actors to stay onscreen while the cutscene is playing until the last frame, then remove them as the real Sleeping Guard comes back onscreen. Either drag the track back one frame or set the End setting one frame back from the track’s duration.

Activation track used to have the sleeping guard cutscene actors game object to stop playing before the last frame of the animation.

When we play the game and the player collides with the Security Guard’s desk, we see the cutscene playing. However, there is another problem arising with the player still onscreen in the cutscene.

Cutscene actors appearing in the cutscene, but the Player game objects is still active in the scene.

Create one more Activation Track and drag the Player game object into its slot. Set the Player’s track to reappear one frame before the End frame value.

Activation track used to disable the Player game object and reappear at the last frame of the cutscene.

Now when the player collides with the Guard’s desk, the cutscene will play with the Security Guard and Player game objects disappearing from the cutscene playing. Then see them reappear when the cutscene ends.

Player now removed from cutscene and reappears when it’s done.

--

--