Ok, so, my issue is this.
When the below code is executed, and the return percentage is not 100%, it will return with a percentage of 0%
This is the maths equation;
CurrentHP/MaxHP * 136(136 is the width of the health bar in pixels) = x
So, if, CurrentHP = 10, MaxHP = 100 it should equal 13.6! However, in Unity3D, it returns with 0 unless Current and Max HP are exactly the same (i.e. Full Health)
I am stuck on this, and for the life of me, cannot understand how this simple mathematics equation is returning anything BUT the expected value, Unless, for some strange reason, the C# code is returning whole numbers All the time (specifically for the CurrentHP / MaxHP part of the equation)
IF, the currentHP was equal to 10, and the maxHP was equal to 100, this part of the equation would equal 0.1, in which, if this was converted to a whole number, it would equal 0.
Any help would be appreciated.
ACTUAL CODE;
public class thisClass : MonoBehaviour {
private Rect healthbarRect = new Rect(111.00f,51.00f,136f,20f);
void Update(){
healthbarRect.width = 136 * (character.curHP / character.maxHP);
}
}