My journey becoming a Unity game developer: Audio Manager: Intro Cutscene Camera Fix and Skip Intro
Objective: Fix the Main Camera’s position after the cutscene finish playing. Also, create a way to skip the cutscene using the “S” key to begin playing the game.
To fix the Main Camera issues following the Intro Cutscene ending we will start by creating a Virtual Camera, and name it CM Final Shot. We’re going to drag the CM Final Shot object into the Camera One Progression Angle to serve as the position where the Main Camera will return to after the cutscene finishes. Set the Transform positions and rotations to zero, and click the Solo button of Status: Live under the Cinemachine Virtual Camera component to officially set the CM Final Shot camera to the Camera One Progression’s position and rotation. Place the CM Final Shot object into the CM Virtual Cameras inside of the Intro Cutscene game object.
Go into the Intro Cutscene Timeline editor, in the Main Camera timeline right-click and Add Cinemachine Shot to the timeline. Attach the front of the shot to the last virtual camera shot, and drag the end of the shot to the last frame of the cutscene’s duration. If we don’t place it to the end of the shot, the Main Camera will position itself to the last camera position in the cutscene itself which will be the wrong position. With the cinemachine shot still selected, drag the CM Final Shot object into Virtual Camera slot under the Cinemachine Shot component in the Inspector.
We can now play the game and watch the cutscene play to the end. After the cutscene finishes, we will notice the Main Camera positioned overhead in the Camera One Progression’s location.
We also see after the cutscene finish playing, the player can now play the game as normal.
Let’s do one more thing which is to use the “S” key to skip the Intro Cutscene. Go to the Game Manager script, and use the namespace UnityEngine.Playables to gain access to the Playable Director class. Next, we need to create a variable with the Type Playable Director name introCutscene as this variable will serve as a reference to the Intro Cutscene game object.
Then using the Update() function, check IF the key that is pressed is the “S” key. Now if it is, our instinct would be to use the Stop() method. The Stop() method stops playback of the current Playable and destroys the corresponding graph according to Unity. This means that the cutscene will stop playing when the “S” key is pressed, but the method will destroy everything associated with the cutscene in the timeline. Therefore, the Main Camera’s position will be located somewhere else in the room making the game not playable.
Instead, we will use the Playable Director’s time property. The time property uses the component’s current time, and this value is incremented when it is playing. We will set the time to the end of the shot’s duration to stop the cutscene from playing immediately. In this case the time will be set to 62.5f which will be the last frame in the shot.
Select the Game Manager game object and drag the Intro Cutscene game object into the Intro Cutscene variable’s slot under the Game Manager script component. This will now give us a reference to the Intro Cutscene itself, and allow us to skip the cutscene when we press the “S” key.
Start the game and press the “S” key while the cutscene is playing. We will see the cutscene stop immediately and go right into game mode for the player to begin playing.
Now that we finished with the Audio Manager, we will work on the Main Menu next time.