Scaling GUI Label not working?

I’m trying to create a health bar that shrinks as the variable health decreases, but it seems to only decrease once health is at 50 or lower. As if it’s only going to decrease by half values of health… Is there something I’m not doing right with this code?

GUI.Label (Rect(.06 * Screen.width, .89 * Screen.height, .30 * Screen.width / (100/health), .04 * Screen.height), "" + health, healthStyle);

Thanks if you can help!

Try this:

GUI.Label (Rect(.06 * Screen.width, .89 * Screen.height, .30 * Screen.width * (health/100.0f), .04 * Screen.height), "" + health, healthStyle);

My guess is that your variable for keeping health is an int so it would truncate the result at the division (100/health) and thus the wrong behaviour. But if you put 100.0f instead of 100, it gives you the precise result with decimals.