Retro “Game Over” Behaviour
Being around in the 80’s isn’t a requirement when it comes to wanting to recreate that old school vibe.
In this article, I’m going to show you 3 ways we can create
The first thing we need to do is to add a Text element to our scene. Unity provides 2 different types of Text…a simple Text element and a TextMeshPro element. The difference between the 2 isn’t much but TextMeshPro offers a wider range of options so I will be using that one.
Let’s set up our text:
In the “Text Input” you can change the “New Text” to the actual text you want displayed. I’ve aligned my text to be centered within the text box and then I changed the x and y position to zero. By default, Unity sets up the TextMeshPro boundary to the center of the screen.
We can change the anchor position within the rect transform by clicking on the target:
Changing the anchor point reflects in the scene:
Now that we have our text in position, it’s time to create that old school flicker vibe.
The first method is with code. We will get access to our text element and deactivate it and reactivate it with a simple IEnumerator:
In this example, we activate the text for 1 second, and deactivate it for 0.5 seconds which gives us the following result:
Instead of activating and deactivating the text, we could also set the text property to an empty string like this:
Another way we can accomplish this is with the Animator component. You can manually adjust the alpha from 1 to 0 to have the text disappear and reappear: