- Home /
Health bar help
Alright i'm currently running through the Bergzerg Arcade "hack and slash" tutorials and i wrote this health script off of what he did. It worked a while ago but apparently now it doesn't. (or i just wrote it wrong.) I get no errors but The GUI health bar doesn't pop up in my game view. So anyway here is the script: 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); } }
Ive got a feeling its a simple issue but i can't figure it out. Thanks for any help!!
Answer by senad · Feb 22, 2012 at 09:51 AM
You mispelled the OnGUI() method. (upper/lower case does matter)
The way it is in your script right now, the OnGUI() method is not overwritten, but a new method with a different name is defined.
:)
Your answer
Follow this Question
Related Questions
Score display not working 1 Answer
GUI box scaling issue [C#] 0 Answers
Complex health bar using GUI.BeginGroup for clipping? 0 Answers
Enemy Health Bar problem Unity 2D. 1 Answer
Curved health bar 0 Answers