Question Text not changing

So I’ve followed the tutorial and the else statement is working. The Correct answer is being highlighted, and yet the question text is not printing the correct answer. Anyone else encounter this issue and or have a solution?

Hi Daigus,

Welcome to our community! :slight_smile:

The Correct answer is being highlighted, and yet the question text is not printing the correct answer.

What is ‘the correct answer’? And what does your game show instead?

The logic flow is the following:

  • The player clicks a button.
  • The button sends an integer to the OnAnswerSelected method.
  • The method compares the received integer with the correctAnswerIndex. Based on the result, which is either true or false, we display text and highlight a button.

Check your game again. You know what you expect to see, and based on the logic flow, you know what you expect to go on behind the scenes. However, you cannot see what the computer is doing, so if you cannot find the problem, use Debug.Logs to figure out if the expected integers get sent and compared.

If you do get the expected integers, remember you can also look at the lecture code changes via the link in the Resources of each lecture. A little typo, expecially in if-statements, can result in an unexpected outcome.

Did this help?


See also:

Thank you for the reply,

I figured out the issue. All of the buttons were assigned the same integer in the index, so it wasn’t able to distinguish the different answers.

I’m glad you solved the problem. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms