From 687dbe82b779d68ffbccb859cc2bc92251e9bd16 Mon Sep 17 00:00:00 2001 From: MartinRemi Date: Mon, 30 Nov 2015 18:24:35 -0500 Subject: [PATCH] Removed life when falling --- Assets/Scripts/FallCheck.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Assets/Scripts/FallCheck.cs b/Assets/Scripts/FallCheck.cs index 16cb63e..4de2a92 100644 --- a/Assets/Scripts/FallCheck.cs +++ b/Assets/Scripts/FallCheck.cs @@ -1,15 +1,24 @@ using UnityEngine; using System.Collections; +using UnityEngine.UI; public class FallCheck : MonoBehaviour { public GameObject player; public GameObject cam; + public Text health; // Update is called once per frame void FixedUpdate () { if (player.transform.position.y < cam.transform.position.y - cam.transform.localScale.y) + { player.transform.position = new Vector3(0, 0, 0); + health.text = "Health: " + player.GetComponent().removeHP(1); + if (player.GetComponent().getHP() == 0) + { + player.GetComponent().Death(); + } + } } }