2D Galaxy Shooter — Making a Flickering “GAME OVER” Display!

Hello all!

Today, I will be going over how to make a flickering “GAME OVER” display in the UI on player death!

GAME OVER! Look how retro that is….

Creating the UI Text Object

  1. Much like the Score_text, at the top-left of the hierarchy, click the +, down to UI, then Text.
  2. Rename it “Game_Over_text.
  3. Position the text to 0, 0, 0.
  4. In the Text component, set the text to “GAME OVER”, set the font size to 50, the alignment to the middle, set both horizontal and vertical to “overflow”, and the color to white.
  5. At the top-left of the inspector, click the checkbox, which turns the text off.

Basic GAME OVER Behavior

Today everything will be in the UIManager script!

  1. Add variable — [SerializeField] private Text _gameOverText;
  2. Link the Game_Over_text to the script component in Canvas.
  3. In Start(), add: _gameOverText.gameObject.SetActive(false);
    This makes sure the game does not start with the GAME OVER display on.
  4. Head to the method = UpdateLives(int currentLives)
  5. Add the if statement:
  • If the Player’s lives reach 0, then make the GAME OVER active.

Flickering GAME OVER Behavior

Time to use some coroutines to choreograph events!

_gameOverText.enabled is used to turn on and off the Text component
  1. Add the new IEnumerator method above.
    - By making it false first, then it gives it a half second to show up so it’s not so abrupt.
  2. Then start the coroutine in our new if statement in UpdateLives():

Now test it, it‘s starting to look more like a retro space shooter!

That was how to make a flickering GAME OVER display on your UI! Next, I will go over how to make a starting screen to get our player ready to fight!

Thank you for your time!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Marcus Cohee

Marcus Cohee

I am starting Unity and learning the ropes as I go! Let’s take this journey together!