GameDev : the Game Manager!

Matteo Lo Piccolo
3 min readJun 21, 2021

--

Here we are, and now we need to talk about the Game Manager.
Normally, in the Games, there is always a Game Manager who manages every single aspect of the Game.
He is a bit of the “director” of our game.

It acts as like UI Manager, but it manage the FLOW of our Game.

We starting to create it

And we need a script

Look at this

Internally, Unity knows about Game Manager, and set it with a GEAR ICON.

Open the script.
Inside, we delete for now Start and Update, and we create a bool for Game Over. Why?
Because it is the Game Manager and it has to KNOW when the Game is Over.

Now we need a method to set bool to true when the Game is Over

After this, from HERE we create Update() method, and check

So what should we do?

A simple thing : we cut the code inside UI Manager

and paste it in Game Manager

We have errors, don’t worry about it.
First, ALT+ENTER on SceneMagaer and add
using UnityEngine.SceneManagement;

Then change
_restartText.enabled == true
with
_isGameOver == true

Now we have set the right method in the right place.
We have already added the scene to the Build Setting, so the last thing to do is call the Game Over method.

Go to UI Manager and create a reference to the Game Manager

And in the GameOverSequence() call
_gameManager.GameOver()

If we test it

And everything is fine, but the logic is much better than before.

--

--

Matteo Lo Piccolo
Matteo Lo Piccolo

Written by Matteo Lo Piccolo

Always in love with programming, even if late (I'm already 39 years old) I decided to follow my dream! We will see how far my passion will take me!

No responses yet