Creating a Retro Game Over Behavior

Niraj Karki
2 min readMay 15, 2021

--

Day 23- Making 2D Space Shooter Game

In the previous article, we learned how easy it is to build an UI for our game and now we will create a Game over behavior.

Now let us create a Game over text and anchor it to center of the screen. Then change its properties to your liking.

Now toggle the Game over text to inactive. We don’t want to show this text when the player is playing and only want to show when the player dies. So we will be setting it as active when the player dies.

Create a method that is going to control the Game over text when the player health reaches zero. we used _isGameOver bool variable to tell the game that player died and it will be used further into the development to add more functionalities when player died like a game restart. Call this method when the player dies for it to work.

Create a coroutine to generate a flicker behavior for the game over text. the flicker continues infinitely so the while loop always continues.

And this is what it looks like.

--

--

No responses yet