How to create a retro game over text effect in Unity
GAME OVER. The 2 words a gamer hates to see (apart from maybe microtransaction or loot boxes). I can still remember the first time I saw the game over screen in crash bandicoot, that brings back a lot of memories.
In this quick guide, we are going to show how to create flickering text, colour change, and typing effects in Unity
First, we need to create our game over text object and apply logic to tell us the game is over. I have created an event on the player that gets called when the player runs out of lives and the UI manager has subscribed to it.
Next, we want to start a coroutine that runs while the game is over. Here we want to type our game over string letter by letter.
We create a variable that stores our game over string (GAME OVER….) and then place it inside a “for loop”, which will run as many times as we have characters. We can check our string length using “stringName.Length”
We can use a substring that increases in length with the value of “i”.
So now we can test this function.
That’s not a bad effect, but we still need to add a random colour element. So we quickly create a function for a random colour and add it to our “for loop”.
Now we can test it.
That is starting to look good but there are two more things I’d like to do to polish this effect. First, let's add another wait when the text has been completely typed out where we just flicker the colour and text.
Secondly, did you notice that our text typing effect also “types” out the empty space between “game” and “over?
In-game it kind of looks like we drop a frame or there is a pause. What we can do is check the character we are currently typing and only pause if it is not a space.
So we can test new functionality now.
And there we have it. A nice game-over-text effect was added to our game.
That’s all for now.