Managing Your Scene in Unity

You’ve set up everything in the scene: the environment’s layout, the enemies’ logic, the player’s control, added win/loss scenarios, and even audio and cutscenes. Does this mean it’s ready to be published? Technically yes, as you have a functional scene; however, to truly make it a game, you’ll have to tie everything together. What happens if the enemy damages the player? How about when to play a cutscene or an audio? When should the win/loss scenario execute? This is where game managers come in.

What is a Manager?

Like its name implied, managers sits on the top and “manages” the scripts by keeping track of what’s going on and what should each script do. A great example of how a manager work is a hub-and-spoke model used by transportation companies: the individual scripts (spokes) will relay information to the managers (hubs) and, in turn, the managers will relay the newly updated information back to the other scripts.

An example of a hub-and-spoke system; the hub are in red while the spokes are in black

Even though information might take longer using managers to send and receive information, it decreases the chances of “communicaiton” errors.

For instance, if the enemy has damaged the player, I need to update the information about the player’s health. Although it might be fine if dealing with a few enemies, but when there are other things that can damage the player, it creates a lot of conflicting information for the Player’s script to process. As a result, it’s better to pass the information to a manager so they can process it and update the player’s health accordingly.

Types of Managers

From audio to UI, you can essentially create managers for anything. Nevertheless, if you’ve have to create one manager to control everything, it should be a game manger.

The Game Manager script (the gear icon)

Fortunately for us, creating managers in Unity, whether it’s the Game, Audio, or even UI Manager, is simple: create a new script and attach it to a game object (ideally an empty one) in the scene.