- Home /
Any idea why my int wont display on GUI
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.
Comment
Best Answer
Answer by Bunny83 · Nov 26, 2015 at 05:44 PM
It's OnGUI
not onGUI
^^
YAY! Thank you very much, I hate it when there is a syntax error that you just cant see.
Your answer
![](https://koobas.hobune.stream/wayback/20220612050452im_/https://answers.unity.com/themes/thub/images/avi.jpg)