Creating a Retro Game Over Behavior

Today we’re adding a retro game-over behavior. We want the GAME OVER text to flash on the screen.

First we add a new UI Text element to our canvas, and then we can either update the text from blank to GAME OVER, or we could just activate and deactivate the text. Let’s activate and deactivate the text element using gameObject.SetActive().

We’ll need a reference to the text element, so we serialize the variable and then drag and drop our text element onto it in the Unity UI. Now we can set the value of SetActive using {variable_name}.gameObject.Setactive() like this:

Adding a WaitForSeconds function gives us the alternating active/inactive retro-flashing effect.

--

--

--

Unity and Flutter developer interested in creating mixed-reality applications.

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

Recommended from Medium

Web3 Rabbit Hole Roundup // Week 2: DAO Platforms, Etc.

Original art with rabbit coming out of rabbit hole with series title "Web3 Rabbit Hole Roundup

Learning Swift and iOS Development Part 6: Loops

Cloud Lock In — something to think about

Cycan Network X Polygon Giveaway

Installing IRAF/PyRAF on Mac with Linux VM

7 Tips to stay healthy as a software developer

Regular Expressions: Sub() Method and Verbose Mode

Snippet: A Piece Of Code [Technical Term]

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
Richard Morgan

Richard Morgan

Unity and Flutter developer interested in creating mixed-reality applications.

More from Medium

Unity — new input system create an action map

Quick tip — Upgrading your Unity project to High Definition Render Pipeline (HDRP)

Adding a health powerup to our prototype

Daily Progress: Main Menu Functionality!