The Game Manager
In the previous chapter, we introduced the GameMangerScript
, but even after the second implementation of waypoints, we have left this script empty with no use. However, we do indeed need a game manager in our game to handle a couple of things. So, in case you have erased it from the last chapter, recreate it, along with a game object in the scene with such a script attached (the same way as if you erased the reference from the PandaScript
, because we will need it later on).
We will use the Game Manager
as a hub for exchanging information between the player's health and the Pandas. In fact, the Game Manager
will spawn Pandas in the scene divided into waves, and it's the only script to be aware of when the level starts and finishes and/or if the player has lost all the health. This makes the Game Manager the perfect candidate to handle and trigger the game over conditions. Let's start with them.
Game over conditions
When does our game reach an end? Well, there are two cases:...