Creating a Retro Game Over Behavior

Michael Lam
2 min readSep 10, 2023

--

Today, I learned the proper way to create flickering text in Unity for my Game Over text.

Initially, I thought that I could just write a while loop in my script where the text is to be displayed and that would be fine.

However, I forgot the most important rule: Always have a while loop in an IEnumerator routine so that you can use the “Yield return” code, otherwise your game will freeze and crash. After remembering this rule, I rewrote the code inside an IEnumerator routine and now the flickering works without freezing or crashing.

I also learned that theres a couple different ways to simulate the flicker. I could either rewrite the text entirely and switch between “Game Over” and nothing like in the picture above.

Or, I make it so that the text object itself becomes visible and then invisible over and over again.

--

--