Creating a Retro Game Over Behavior

Siddhant Thakur
Apr 19 · 3 min read

In the previous article we saw how easy it was to build a UI in unity. Let's build upon it further by adding a Game Over Screen once the Player has no Lives left.

For starters let’s create a Game Over UI Text component which will be displayed when the Player has zero lives left.

This should create a Text Object within our Canvas. Edit it and place it and anchor it to your desired position.

Here, Text component has an interesting field called Horizontal/Vertical Overflow, this can be useful when your text exceeds the defined boundary which makes your text invisible.

Then we can select the Overflow option to make the text ignore the Text boundary.

With our Text UI ready for use lets have it be deactivated by default, and only active when the Player has no Lives left.

With this done let’s code our Game Over behavior, we want the Game Over text to flicker over fixed intervals of time to give it a retro game vibe, and since we’re dealing with a routine/time interval type of logic, we can use Coroutines(to learn about Coroutines click here),

Now let’s define the flicker behavior,

When the above function is executed the Game Over Text object will be toggled ON and OFF every half second. Giving us a flicker behavior.

Let’s call this function in our UpdatePlayerLives() where we keep track of the number of lives the Player has left(UpdatePlayerLives was defined in the previous article).

This gives us the following result,

Thank you for reading. More to come!!!

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

Siddhant Thakur

Written by

Aspiring Game Developer with experience in the field of Machine Learning.

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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