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

CS371p Fall 2021: Sean Yu

Leetcode Q197. Rising Temperature (Q189)

Should you really use Streams?

Python Lambda Function

Spring Boot with Lombok

Let’s start with nmap without flags to save time while in the background we run another one with…

A quick Introduction to Apache Airflow

Building container-based development environment with Visual Studio Code

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

My journey becoming a Unity game developer: 2.5D Infinite Runner-Ledge Grab System-Pt3

Building a Procedural Game #1: Island Generation

New Enemy Movements: Up and Down/Side to Side

Player 1 Is Ready To Move Around