Draw Health bar

How to draw health bar based on variables percentages?

When you scale a spite the initial value is 1 you can think of it as 100%.
0.1 is basically 10% of it initial scale
1.1 is 110% of it initial scale.

While keep this in mind, you can simply change the scale of the health bar on the X axis (width) using the value of the health divided by 100.

Do= health / 100 to the width scale of health bar

If health is = 100, it make the scale of the health bar to be 1 which is the initial size, no changes
If health = 50, it make the scale of the health bar to be 0.5 which is the half of it initial size which is exactly what we want.

Of course to make it work, the initial health value need to be 100.

Here is an example:
health_bar.zip (3.21 KB)

Omg, why wouldn’t I thought of that? Thanks!