Game Manager
Part 1: Reload level when dead
Player
- Create a playermodel with a collider and a rigidbody
- Add the Health.cs script and change these parameters
- Check the "Is Alive" box
- Put it on "Load level when dead"
- Add your level name
Deadzone
- Create a object you want to be your border/deadzone
- Give this object a collider and check the "Is Trigger" box
- Add the Damage.cs script
- Check the "Damage on trigger" box
Part 2: Game Over overlay with reset button
- Change on your playermodel "Load level when dead" to "Do nothing when dead"
- Create a main canvas (this one will be visable when alive)
- Create a game over canvas (will be visable when the player is dead)
- Add a text field (used to display Game Over)
- Add a button
- Add the ButtonLevelLoad.cs script onto the text field of the button
- Add the name of the level you want to load when resetting the game
- Create a new function in the button
- Drag the text field from the button that holds the ButtonLevelLoad.cs script into the empty object
- Open the No Function option box and pick ButtonLevelLoad and then pick Loadlevel()
- Disable the "game over" canvas by unchecking it
- Create a empty object called gamemanager
- Add the GameManager.cs script
- Add you playermodel to Player
- Add the main canvas to Main Canvas
- Add the game over canvas to Game Over Canvas
- And put the game state on Playing