SHARE
TWEET

Untitled

a guest Jan 24th, 2020 73 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.             health = 0;
  22.                 }
  23.             if (health == 0 && !hasDied) {
  24.             hasDied = true;
  25.             StartCoroutine ("Die");
  26.          }
  27.     }
  28.     IEnumerator Die () {
  29.         SceneManager.LoadScene ("SampleScene");
  30.         yield return null;
  31.     }
  32. }
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