using UnityEngine;
using System.Collections;
public class HealthCoLL : MonoBehaviour {
public float health= 3.0f;
public static GameState gameState;
// Use this for initialization
void Start () {
GameStart ();
}
public void GameStart(){
gameState = GameState.playing;
Time.timeScale = 1.0f;
}
public void GameOgre(){
gameState = GameState.gameover;
Time.timeScale = 0.0f;
}
void OnTriggerEnter(Collider coll)//when ienemy bullet collides with the player subtract 1 health
{
if (coll.gameObject.tag == "Can")
{
health-=1.0f;
}
}
void Update () {// Update is called once per frame
if (health < 0) {
GameOgre();}
}
}
When the player is hit with enough bullets to put the health float below 0 GameOgre doesn’t run even though the if statement in void Update says to. Please help.