mirror of
https://github.com/ConjureETS/Labo_2_equ_2_a15.git
synced 2026-03-25 01:51:06 +00:00
Removed life when falling
This commit is contained in:
parent
8447b8123a
commit
687dbe82b7
@ -1,15 +1,24 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class FallCheck : MonoBehaviour {
|
public class FallCheck : MonoBehaviour {
|
||||||
|
|
||||||
public GameObject player;
|
public GameObject player;
|
||||||
public GameObject cam;
|
public GameObject cam;
|
||||||
|
public Text health;
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void FixedUpdate () {
|
void FixedUpdate () {
|
||||||
|
|
||||||
if (player.transform.position.y < cam.transform.position.y - cam.transform.localScale.y)
|
if (player.transform.position.y < cam.transform.position.y - cam.transform.localScale.y)
|
||||||
|
{
|
||||||
player.transform.position = new Vector3(0, 0, 0);
|
player.transform.position = new Vector3(0, 0, 0);
|
||||||
|
health.text = "Health: " + player.GetComponent<Health>().removeHP(1);
|
||||||
|
if (player.GetComponent<Health>().getHP() == 0)
|
||||||
|
{
|
||||||
|
player.GetComponent<PlayerBehavior>().Death();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user