Incorrect Score Bug

Hey folks, this was wrecking my head but I had a bug where the “questionsSeen” variable was always 1 more than “correctAnswers”, so if I answered the first question correctly the score would show 50% instead of 100%.

After digging around the code for a while I found that the problem was with “loadNextQuestion” in the Timer script. Essentially, that was being set to true for the first two frames of the game rather than true then false. To fix this I changed the script execution order so Timer would execute before Quiz. The UpdateTimer() method was setting loadNextQuestion to true on the first frame AFTER Quiz had set it to false, ensuring the Timer script runs first solved this issue.

Hope this helps anyone who was running into a similar bug.

4 Likes

Thanks for this. I kept getting an exception from the line “correctAnswerIndex = currentQuestion.GetCorrectAnswerIndex();” since no question had been set. This fixed that.

Privacy & Terms