Take card from sleeping guard

Hal Brooks
2 min readAug 28, 2021

Objective: Trigger sleeping guard cutscene to take card and return to game.

To achieve this goal the Player, Darren, must approach the sleeping guard to trigger the cut scene. The cut scene is allowed to complete and the player is returned to the game. Use Grab_Cut_Scene_Zone to integrate the behavior of the Player with the Sleeping_Guard_Cutscene and Main Camera.

Finished integration of the cut scene with the game.

Use a box collider on Grab_Cut_Scene_Zone, shown below, to trigger the Sleeping_Guard_Cutscene.

Box collider for Grab_Cut_Scene_Zone.

The Grab_Cut_Scene_Zone needs the following components to work. Notably, the box collider with is trigger checked and Grab Key Card Activation C# script.

Grab_Cut_Scene_Zone components.

The code below shows the use of serialize fields to assign the variables for the cut scene, _grabCardCutScene, and the position for the main camera at the end of the cutscene, _cameraEndScene, which are assigned as shown above.

Variables for activating the sleeping guard cut scene.

The Player already contains a rigidbody, so an OnTriggerEnter method is used to detect the collision. If the Player is the other collider then activate the cutscene, as shown below. To return to the game, a coroutine is called, InactivateCutScene.

OnTriggerEnter method in GrabKeyCardActivation script.

The IEnumerator coroutine, InactivateCutScene, waits for 6 seconds or the length of the cutscene timeline, and inactivates the cutscene. The main camera position is set back to Camera_Five held in _cameraEndScene, which is the Camera_Progression_Angle nearest the Sleeping_Guard.

InactivateCutScene coroutine in GrabKeyCardActivation script.

--

--