Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class Player_Health : MonoBehaviour
- {
- public int health;
- public bool hasDied;
- // Start is called before the first frame update
- void Start() {
- hasDied = false;
- }
- // Update is called once per frame
- void Update() {
- if (gameObject.transform.position.y > -7) {
- health = 0;
- }
- if (health == 0 && !hasDied) {
- hasDied = true;
- StartCoroutine ("Die");
- }
- }
- IEnumerator Die () {
- SceneManager.LoadScene ("SampleScene");
- yield return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement