Framework 1: Respawning

Because I suck at playing this game, I need a respawn!

Scripting

For this feature to function properly, we need to be addressing several components. The Player, the UI manager, the Spawn manger and the Game manager. Since each part is basically linked to each other, it is important not to forget any of these components.

The Player:

In the player script, we first need to create a handle for the player game object. Then in the Damage method we are going to do some small changes, instead of destroying the player when Lives = zero. We are simply going to disable the the player.

The Spawn Manager:

In the spawn manager script we need to add another new public method with a Boolean to tell the stop spawning to be false. This is to counter the “On Player death” method which tells the spawn manager to stop spawning.

The Game Manger:

In the Game Manager, we again are going to create a new public method to counter the game over method.

The UI Manager:

Finally the UI manager, where everything comes together. In the previous article we have already mention that we have already created an public method called Game Over. Now its time to create another public method called Respawned.

The Respawn Button:

Save everything, and back in the hierarchy select the respawn button on the Game over menu. In the “On Click” area, we are going to add a new function and drag the the Canvas component (since it has the UI Manager script) and select the public function “Respawned”.

--

--

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

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
Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.