First, I have to say that im a beginner scripter, please be patient with me thx :D.
So, I tried to create a health bar for my player and I came up with this script :
public int maxhealth = 100;
public int curhealth = 100;
public float healthlength;
void Start ()
{
healthlength = Screen.width / 2f;
}
void OnGUI()
{
GUI.backgroundColor = Color.red;
GUI.Box(new Rect(10, 10, healthlength , 20),curhealth +"/"+ maxhealth);
The problem is that whenever the hp drops, the bar shortens instead of shortening the content inside. And also, I cant turn my health bar to the colour I want either.
↧