Top Down Shooting Game (part 6)

Continuing my last post, I create a Game Over screen and it just pops up when the player dies. And create a Play Again button, it will restart the game. I applied what I learned from the Flappy Bird tutorial and got my Game Over screen working.


In the Hierarchy, create a canvas called Game Over Screen. And in this canvas create a text and a button. Edit the text to Game Over and change the button’s text to Play Again. Then you will have a Game Over screen like below.

To get the Play Again button working, I simply created a game object called Logic Manager and a new script called Logic Script.

Then in the Logic Script, import the SceneManagement and create a function called restartGame(). In this function, write SceneManager.LoadScene(SceneManager.GetActiveScene().name).

Return Play Again button to add event to it. Move Logic Manager to Runtime Only and select the Game restart() function. It causes the Play Again button to call this function when it is clicked.

Next is to make the Game Over Screen only appear when the player dies. Uncheck the Game Over Screen and create a gameOverScreen variable. Then create a gameOver() function, this function will make the Game Over screen turn on when call it.

And in the Inspector, move the Game Over Screen to the Game Over Screen of Logic Manager.

In the Enemy script, create a bool variable called player_is_alive, set it true, and a logic variable. And set the logic is equal the Logic Script of a gameObject that have a tag “Logic” in the Start() function. And in the function that check what object is collided with enemy, If the collided object is “Player”, set the player_is_alive is false and call the gameOver() function of Logic Script.


Because my game camera is small I can’t set the canvas to create text and buttons. So it took me a while to resize my camera, player, and enemies. Also changes the speed and position of the player and enemies. And resize and change the speed of the bullets.

Because command I did to make enemies speed is moving by a pixel. And the Camera is bigger so I have to make it times 100 to make it faster.

And do same thing in the Player Movement, I make the move speed times 50 to make the player move better.

And this is my game

Tags:

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *