Creating a Retro Game Over Behavior

Let’s create more UI to better show that it’s Game Over.

Let’s add a Text component to our Canvas, and position it as desired.

We only want this to appear when it’s actually Game Over time, so let’s disable it. Now within our UI Manager script, it’s also good practice to make sure it’s disabled at the start of the game. Let’s create a variable to store the Text object and we can then do the following in our Start method.

Now, we could create another public method for the Player to call when Lives is equal to 0. But we are already sending this variable to the UI Manager for our live’s sprites. So let’s use an if statement to check what that value is and then call a private method for our game over functions.

Within the GameOver method, we could now simply set the game over text to active. But we want more of a retro flicker. To do so, we can use a Coroutine and a while loop.

With this, every 0.5 seconds the Game Over text will appear then disappear.