Problem with calculating damage, value returning 0

Hello guys I was trying to calculating the damage that the player would receive although if defense value is different from 0 the result will always be 0, i know I must be missing something but i cant figure out why, can anyone help?

I’ve tried to round it , to cast it as either float and double but couldn’t fix it.

Thanks in advance.


float healthToLose = (damage * (100 / (100 + defense)));
health -= (int)Mathf.Round(healthToLose);

Its data type casting problem. Try to use 100f instead of 100. Or cast damage to float. Or use all of this