Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Creating A GUI health bar

$
0
0
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.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>