Creating A Retro “Game Over” Behavior

In a lot of games throughout history, they had a function within the game that depicted the player’s death as a “Game Over” sequence.

This is super easy to implement into a game and I am gonna show you how!

This script will be attached to the player object…

You will have to create a UI Text object to print the words “Game Over” on your UI.

Then within your scene in Unity, you will need to reference the “Game Over” text object by dragging and dropping it into the “_gameOverText” reference box on your script.

Essentially all you are doing is:

  • Creating a number variable to represent life for the player.
  • Then referencing that life in order to subtract it when you take damage.
  • And last, if you run out of life, destroy the player and activate the “GameOverText” object!

--

--

--

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

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

Recommended from Medium

How to create Animated FAB Button in IOS Swift UI

Developer Insights: The 2019 BrainStation Digital Skills Survey

How to Host Unity Games on the Web

What is the Cloud, and Why Do Businesses Rely on it More Than Ever?

Microservices Framework and DevOps Development: Get the Best of Both Technologies

Host your own Cloud Storage — /e/ OS shows the way

Get Fluttered: A Simple Bottom App Bar Part #1

Ryzen 5 3600 vs Ryzen 7 2700X by Hi! TechTalk

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
Adam Reed

Adam Reed

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

More from Medium

Day 7: The Enemy

Unity: Adding and Removing Objects

Devlog 28: Added A Charged Shot To My Game

Make a new Bullet Varient/Power up/Pick up/Boost