- Home /
 
               Question by 
               christehchris · Jun 01, 2012 at 09:05 PM · 
                c#healthbarhealth  
              
 
              What's wrong with this health bar GUI script? (C#)
The script I'm using just doesn't show up at all on the screen when put on First Person Controller... What's wrong with it? I'm not getting any errors.
using UnityEngine; using System.Collections;
public class PlayerHealth : MonoBehaviour { public int maxHealth = 100; public int curHealth = 100;
 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
 
 }
 
 void OnGui() {
     GUI.Box(new Rect(10, 10, Screen.width / 2 / (maxHealth / curHealth), 20), curHealth + "/" + maxHealth);
 }
}
               Comment
              
 
               
              Answer by CSE_DHancock · Jun 01, 2012 at 10:00 PM
You have the function named "OnGui()" but it should be "OnGUI()"
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnGUI.html
Your answer
 
 
             Follow this Question
Related Questions
Semicircular Health/Mana/Progress Bars 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Health Bar Messages 3 Answers
How do I expose a health serialize script on a health bar ? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                