SHARE
TWEET

Player Health

a guest Jan 24th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top