The score shows accurately on the scorekeeper throughout the game but it gives an insane percentage on the end screen.
It’s because you are dividing by 0. When the scene changes to the end scene, the scorekeeper is destroyed and a new one is created on the scene. Both questionsSeen
and correctAnswers
are 0, and your calculation becomes Mathf.RoundToInt(0 / (float)0 * 100)
which gives an answer of -2147483648
.
Try it out
int seen = 0;
int correct = 0;
Debug.Log(Mathf.RoundToInt(correct / (float)seen * 100));
thanks. i figured it out. I actually had a typo in my gamemanager script
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.