Joining a cutscene in the gameplay using Timeline

The exercise here demonstrates triggering a cutscene and adjusting the gameplay as soon as it ends.

Timeline is a seriously powerful tool and a cutscene made using Timeline alters the camera positions which has to be restored immediately after the end of the scene.

The project has a sleeping guard cutscene which basically tells a tale of the player grabbing a key card from a security guard. However, that shifts the camera location due to virtual cameras taking over the main camera while the scene is being played.

The task at hand is as followed.

  • Trigger the cutscene.
  • Take note of the visible actors in the scene.
  • Adjust the camera position once the scene ends.

Triggering a cutscene

  • A box object without mesh is deployed around the desk which would capture a collision of the player object.
Unity
  • After enabling the “IsTrigger” and attatching a rigidbody component, add a script to this object with the following simple code.

Note: Do not forget to disable the trigger or else, the scene would run in an endless loop.

C#
Unity

TAKING NOTE OF THE VISIBLE ACTORS DURING THE SCENE

Unity

These two actors are also part of the cutscene and hence, they must be disabled as soon as the scene triggers. Also, once the scene ends, they should return back to their normal position.

Solution?

Timeline asset is a powerful tool, undoubtedly.

Unity
  • Add two activation tracks and drag both game objects.
  • Only activate them at a sweet spot where the fade in is about the end.
  • Disable the scene itself using timeline as soon as these two actors come back alive by simply adding an activation track and cutting it short just a few seconds before the end of the actual scene.
Unity

ADJUST THE CAMERA POSITION

The way cinemachine works is by attaching virtual cameras to the main camera as programmed. Hence, the main camera would continue with the frame of the last virtual camera it was hanging on to.

Solution?

Add a new virtual camera and fix it for a few frames right before the scene is ending and the main camera would have shifted to the location of this last camera by the time the gameplay restarts.

Unity

As seen above, just of the last 5 frames, a new camera comes into the timeline and the main camera will make the switch to it just like any other regular switch.

That should be it :)

Here is the final result.

Thank you very much

Work in Progress.