Day 24: Creating a Retro Game Over Behavior

Objective: Create a Retro Game Over

Start off we will need a Game over text. Right click on Canvas go to UI and Text. Name it Game Over.

Size it to the size you would like and change the color to White. In the Text block, remove New Text and put Game Over.

If the size is to big and the text disappears, you can click on horizontal and vertical overflow and allow the text to over flow the rect area.

To get the Game over to appear when the player dies, we will move to the UIManager. We need to get a reference to the Text object, function to enable it, and to make sure it’s disabled when the game starts.

In the start function we’ll set the game object of this text object to disabled. This is just to make sure we don’t see it when the game starts.

We’ll make a function to enable the object when the player dies.

Now to get the game to call this function, we will move to the player script and when when check to see if lives is less than one, we’ll add this there.

This is how you get the Game over to appear when you die. To make it more fancy, we’ll add some flickering. Back in the UIManager, we’ll create a Coroutine and put the code in a infinite loop. In the loop we’ll wait .5f seconds disable the object, wait another .5f seconds and re-enable the object. I created a global variable to adjust the flicker in Unity.

Make sure you start the coroutine in the game over function. Now you have a fancy game over!




I am passonate on learning to program and use Unity to become a skillful Unity Developer

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

Recommended from Medium

Fixed Team ❌ | Team-Cloud ✅

End-to-end test microservices using Docker and GitLab CI

Using docGen on Windows to Generate Postman API Documentation

A guide to ensuring DevOps readiness

10 Things I Discovered About Choosing A Chat Service

Transitioning from Software Engineer to Project Manager: 9 Lessons You Need to Know

Stilt Raised $114 Million, API Design, APIs & TypeScript

Digital Collage by Bruno Pedro

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
Tyler Smallwood

Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer

More from Medium

Light her up — Adding emissions to your game objects using photoshop and blender

From Prototype to Art

Adding a new ability to our prototype — The Triple Shot

2D Mobile Game: Enemy Class Shared Behavior