Creating a Retro Game Over Behavior

Create Game Over Text and set the Text To Game Over.

I change the Font Size To 50. I Set the Horizontal Overflow and Vertical Overflow to Overflow so I could adjust the size to fit the text. I set the Color of the Text to a light red color, the Screen Background is black. I then Adjust the size in the scene view to fit the text, then adjusted the numbers in the inspector Width of 322 and Height 68. I used the Anchors Button to set the anchors, pivot, and position to the center of the screen.

I Created an Animation to Turn the Text Component off and an Animation to Display the Text Component.

In the Game Over I added a bool parameter called GameOver. I made a transition from the Game Over Not Displayed Animation to The Display Game Over Animation and a transition from Game Over Displayed Animation to Game Over Not Displayed Animation.

I set the Transitions to not have an exit time, to not have a fixed duration, and set the condition to be based on GameOver. True to transition to display and False to transition to not displayed.

I Created a Game Event for when the Player is Destroyed. I added a Game Event Listener to the Game Over Text to listen to the Player Destroyed Event. I was going to have it set the GameOver parameter on the animator to true, but the only option there was Set Trigger. It looks like I am going to have to create a Game Over Behavior.

Simple Behavior that Requires an Animator Component. It gets a reference to that component and has A Method that Sets the GameOver parameter to true.

Now I can set the Display Game Over Method in the Game Event Listener.

When the Player is out of lives the Damageable Calls the Player Destroyed event, as long as you set it on the Player Game Object. When the Player dies the Game Over Text is Displayed.

Now I edited the Display Animation so that the Game Over flickers on and off.

--

--

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
James Lafritz

James Lafritz

Excited about changing my hobby into a new carer with GameDevHQ course.