Hey Folks, I ran into a strange problem: When I try to calculate a chance, it returns zero even though none of the elements of the formula are zero. (I debugged all elements of the formula) Code (csharp): static public int numberOfOnesUsedOnDice = 1; static public int usedDice = 1; static public float chanceToRoleOne =0.0f; static public void setChances() { chanceCoins = (numberOfOnesUsedOnDice / (6 * usedDice)) * 100.0f; } I call the function from a different script when I press a button. Given the debugs all values are properly set/ called during the whole process. But as already mentioned all variables used in the formula are != 0. Any idea on why the formula would return 0? Kind Regards Dawnreaver
You divide int by an int so the result will be int, so if theres something behind the dot it will be cut off so 0.6 will result in 0. Use 6f or cast usedDice or numberOfOnesUsedOnDice to float.