Hey, guys. I’m trying to make a “You Lose!” text appear after touching a stationary object I’ve created a code that should have made it appear but nothing happens when I touch the object. I’m new to unity so I’m sure this is a rookie mistake. Any help would be appreaciated.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Healthsystem : MonoBehaviour {
public int health;
public Text loseText;
// Use this for initialization
void Start () {
health = 100;
SetHealthText ();
loseText.text = "";
}
// Update is called once per frame
void Update () {
}
void OnControllerColliderHit(ControllerColliderHit hit)
{
if(hit.collider.tag == "Enemy")
{
health = 0;
}
}
void SetHealthText ()
{
if (health == 0)
{
loseText.text = "You Lose!";
}
}