Journal 74 — Unity’s “The Great Fleece”, Add Managers

Objective: Add Manager classes to game and fix the Intro, Win, and Game Over cutscenes

In “The Great Fleece”, we have completed all the guard cutscenes and security cameras. Now we want to add Manager classes. For this game, we want to use Manager classes to handle several items: control the win cutscene at the end of the level, check that Darren has the keycard in order to proceed, control the game audio, and allow to skip the intro cutscene.

Game Manager

For the Game Manager, we will use the singleton design pattern. We can start with a new C# script and empty game object.

From there, we can fill out the singleton design pattern.

You can see one example of using the Game Manager to check that Darren has picked up the key card. The Game Manager can be referenced without the need to use GetComponent.

Win Cutscene

We need to update the code and game object at the end of the level to trigger the win cutscene. We need to update the collider so it is set to trigger, and add a RigidBody.

We will add a new C# script to handle the win state.

Now let’s see this in action. We’ll test both scenarios, whether we have the key card or not.

As you can see, Darren is still visible in the cutscene. We can fix this by going to the win level cutscene and adding an Activation Track, and set the Player game object inactive until the last few frames.

Here is the cleaned up results.

Audio Manager

The current audio set up instantiates the voice over clips, and their sound can vary depending on how close they are to the Main Camera. We can create an Audio Manager to make the sound and voice over consistent.

Let’s start with an empty game object for the Audio Manager and VoiceOver, and let’s add an Audio Source component to the VoiceOver object, and a new C# script set up with a singleton design pattern.

Now with the Audio Manager set up, we can a reference to the VoiceOver Audio Source, and a function in the VoiceOverTrigger to pass the clip at each trigger to the Audio Manager to play.

Ambient Music

We can add ambient music. We can create a new empty game object with an Audio Source component and drag in the ambient background music clip. You can adjust the volume slider to your preferred level.

Intro Cutscene

Let’s update the Intro Cutscene. There are four issues to address:

— Darren needs to be set inactive for most of the cutscene and set active again at the end,

— The intro cutscene needs to be set active for the entire clip duration and set inactive at the end,

— The ambient music needs to be set silent at the beginning, and at the end can be turned up in volume, and

— The Main Camera needs to be switched back to match the first overhead shot in game.

Let’s address the first three items, with two Activation Tracks and one Animation Track. For the music, I decided to keep the volume at 0 for most of the cutscene and near the end, ramp from 0 to about 0.39.

For the camera fix, we need to add one more virtual camera, and set this to the Camera_One progression angle. We can do this by temporarily making it a child of Camera_One, zero out its position and rotation, and then drag it back into the Hierarchy.

After that, you can add a new Virtual Camera in Timeline and drag this virtual camera to near the last frame.

Skip Intro

Let’s add an option to skip the intro cutscene. We can look up the PlayableDirector in Unity’s API and update the time, such that when the ‘s’ key is pressed, we skip to the end of the cutscene at about 60 seconds. In order to access the PlayableDirector, we need to add UnityEngine.Playables to the NameSpace. Then we can test this in the middle of the intro.

Game Over Sound and Voice Over

The last item to update is the game over music and voice over.

Now update Timeline with two new Audio Tracks. You can drag and position the music and voice over and volume in the cutscene as you wish.

Thank you for your time!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.