percentageOfPlayer1Hp = new int (((persistence.characterList[persistence.equipedTeam[0]].currentHp)/(persistence.characterList[persistence.equipedTeam[0]].maxHP))*100);
Debug.Log (percentageOfPlayer1Hp);
This is the code returning this error. I need to pull the percentage of a players HP from their current HP compared to their MaxHP.
Remove the new keyword: it’s required for classes, not for a simple int. And if currentHp and maxHP are both ints, percentageOfPlayer1Hp will always be zero: divisions of int by int are integer divisions. You should declare at least one of them as float, or multiply currentHp by 100 before the division - like this:
percentageOfPlayer1Hp = (int) (100 * persistence.characterList[persistence.equipedTeam[0]].currentHp / persistence.characterList[persistence.equipedTeam[0]].maxHP);