Game Manager

Scripts

Size: 2.61 KB

You need to login to download this file.

Part 1: Reload level when dead

Player

  1. Create a playermodel with a collider and a rigidbody
  2. Add the Health.cs script and change these parameters
    1. Check the "Is Alive" box
    2. Put it on "Load level when dead"
    3. Add your level name

Deadzone

  1. Create a object you want to be your border/deadzone
    1. Give this object a collider and check the "Is Trigger" box
  2. Add the Damage.cs script
    1. Check the "Damage on trigger" box

 

Part 2: Game Over overlay with reset button

  1. Change on your playermodel "Load level when dead" to "Do nothing when dead"
  2. Create a main canvas (this one will be visable when alive)
  3. Create a game over canvas (will be visable when the player is dead)
    1. Add a text field (used to display Game Over)
    2. Add a button
  4. Add the ButtonLevelLoad.cs script onto the text field of the button
    1. Add the name of the level you want to load when resetting the game
  5. Create a new function in the button
    1. Drag the text field from the button that holds the ButtonLevelLoad.cs script into the empty object
    2. Open the No Function option box and pick ButtonLevelLoad and then pick Loadlevel()
  6. Disable the "game over" canvas by unchecking it
  7. Create a empty object called gamemanager
  8. Add the GameManager.cs script
    1. Add you playermodel to Player
    2. Add the main canvas to Main Canvas
    3. Add the game over canvas to Game Over Canvas 
    4. And put the game state on Playing

recommended