Creating a game over screen in my space shooter

Right now, nothing really happens when the player is destroyed in my game. Their ship disappears and enemies stop spawning, but the player needs to be reminded of their failures when they are destroyed. They need to be ashamed of their shortcomings. They need to be reminded that success is fleeting and this all could come crashing down at any waking moment.

Boy, that got weird.

Anyway, my space shooter needs a game-over screen. I’ll make a Text UI object and place it somewhere near the middle of the screen. The text within it will say “GAME OVER” and I’ll disable the object so it’s not visible when the game runs.


This method is called indirectly from the player script when the player has no lives left. It’s activating the game-over text and another UI element for a restart functionality.

Just a basic “GAME OVER” is fine, but I want to make it flash on the screen like a retro arcade game. That’s something that’s time-based, so that means I need a coroutine!


I’m only changing the text back and forth between “GAME OVER” and nothing every half-second. Another way of doing this would be activating and de-activating the object itself. Here it is in action:

Next up, I’ll be adding a main menu scene. Don’t touch that dial, folks!