© Casey Hardman  2020
C. HardmanGame Programming with Unity and C#https://doi.org/10.1007/978-1-4842-5656-5_15

15. Death and Respawning

Casey Hardman1 
(1)
West Palm Beach, FL, USA
 

In this chapter, we’ll be implementing a bare-bones system to allow us to “kill” our player (don’t worry, it’s very nonviolent) and send them back to the spawn point.

We’ll set the spawn point when the game first starts, so that wherever we place the player in the scene, that’s where they’ll respawn. We won’t be doing anything flashy for now. When the player dies, their model will disappear, and the Player script will be disabled to keep it from updating. After a few seconds of wait (to punish them for failing), we’ll move them back to the spawn point and enable them again. ...

Get Game Programming with Unity and C#: A Complete Beginner’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.