Hp Bar not working as intended

Pay close attention to this, I’m setting the fill amount of the enemy hp bar to 0.7 to show you everything is set propertly

As you can see, when the hp bar shows it will indeed be filled a 70%
4730630--448016--upload_2019-7-10_11-38-16.png

however, if I set the fill amount to be the result of hp / maxhp, the bar does not even appear as if the fillammount was 0, even though the values are not 0

4730630--448022--upload_2019-7-10_11-44-36.png

4730630--448025--upload_2019-7-10_11-46-43.png

Do you see what I’m doing wrong?

please share

Any errors in the console? Is it possible that the variables aren’t what you expect? You can put Debug.Log before this line and write out the value of these variables into the console.

1 Like

Try (float)(health / maxHealth).

1 Like

Thanks a lot, it actually worked writting (float) (health) / (float) (maxHealth)

Yeah, for integers 14 divided by 20 equals 0.

For bonus points
int a = 20;
float b = 14;
float c = b / a;
print(c);
c = 0.7