Game Over Man! Game Over!

Bill Paxton in Aliens!

Objective: Since we’ve introduced the concept of lives to our game its time to display the appropriate message when our player dies. Nothing too complicated here so let’s dig in.

Implementation: First we’ll add a new Text component that is a child of the Canvas called Game_Over_Text. Then we change the size and color to your choosing. and Importantly make the Text display GAME OVER.

In the UIManager script we create a new text variable called _gameOverText; make it a SerializeField.

Let’s save our script and pop over to Unity. Drag our new Game_Over_text into the empty slot in our UIManager script.

In our Start Method let’s make sure that when we star the game the GameOver text is turned off by adding this line.

And since its now turned off we need to find the best place for us to turn it on. That would be in our UpdateLives() method (which I may not have documented…sorry ;)

That did it! I also added a classic flicker effect by using our old friend a coroutine. Looks pretty great! In the next article I’ll go over how to restart the scene/game after we’ve gotten this screen.




Unity Developer — Technology Leader — Making Unity Game Development Look Easy

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How Object Behave — Chapter 4

What are the advantages and disadvantages of using Bluehost? “Is It The Best Choice for Your Site?”

The Must-Know Tech Jargons for Junior Devs

Make user see only their objects in Django

Pytest for Absolute Beginners

Pytest for beginners

GameDevHQ Crash Course #25 Static Managers

READ/DOWNLOAD*? Exam Ref 70–697 Configuring Windows Devices FULL BOOK PDF & FULL AUDIOBOOK

Weekly Technical Progress Update #12, Sunday September 5th

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
Games Woods

Games Woods

Unity Developer — Technology Leader — Making Unity Game Development Look Easy

More from Medium

How to Switch Between Cameras with Cinemachine and Timeline

From Prototype to Work of Art

Creating A Modular Powerup System in Unity

Saving Data in Unity3D Using Files