using UnityEngine;
using System.Collections;
public class player_health : MonoBehaviour {
public int health = 100; // setup player health and default value
// Update is called once per frame
void FixedUpdate () {
Debug.Log ("PLayer Health : " + health); // display player health (for debugging)
if (health==0)
Application.LoadLevel("Death Screen");
}
public void Increase_Health (int amount) // a function that takes an integer as a parameter and adds this amount from player health
{
health = health + amount;
}
public void Decrease_Health (int amount) // a function that takes an integer as a parameter and subtracts this amount from player health
{
health = health - amount; // This is the function that damage_player is using, giving damage to as 'amount'
}
void onGUI()
{
GUI.Label (new Rect (400, 25, 500, 125), string.Format("{0}", "Health =" + health)); //This displays the health value on the screen.
}
}
I am unsure why the int ‘health’ will not be displayed, I have tried many different methods of displaying it with OnGUI, none have worked, so there must be something I am missing, so I would appreciate a fresh pair of eyes to help me out finding my problem.