Advertisement
Guest User

Player Health

a guest
Jan 24th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class Player_Health : MonoBehaviour
  7. {
  8.  
  9.     public int health;
  10.     public bool hasDied;
  11.  
  12.  
  13.     // Start is called before the first frame update
  14.     void Start() {
  15.         hasDied = false;      
  16.     }
  17.  
  18.     // Update is called once per frame
  19.     void Update() {
  20.         if (gameObject.transform.position.y > -7) {
  21.             hasDied = true;
  22.             }
  23.         if (hasDied == true) {
  24.             StartCoroutine ("Die");
  25.         }
  26.     }
  27.     IEnumerator Die () {
  28.         SceneManager.LoadScene ("SampleScene");
  29.         yield return null;
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement