Game Over, Man, Game Over!

Let’s make a classic “Game Over” screen, complete with flashing text. It’s actually a really simple method and coroutine!


When the player is out of lives, it calls the UI Manager’s DisplayGameOver method. This method displays the “Press the ‘R’ Key to Restart the Game” message and calls the GameOverFlicker coroutine.

This coroutine will turn the “GAME OVER” object (_gameOverDisplay) on and off a number of times (_timesToFlicker), waiting for a very small amount of time (_flickerDelay) in between each on or off. We’re actually telling _gameOverDisplay’s SetActive method to be the opposite of what it currently is each time. So if it’s not active, become active, and vice versa.

We’ll leave a little tooltip for our team to make sure they set _timesToFlicker to an odd number. This way, once the cycle is complete, the “GAME OVER” message will be solid. Because constant flashing is kind of obnoxious.

An independent Unity Developer.