When the game starts it uses 2 questions instead of 1

Hi there, upon initial start of my quiz. It only has 4 questions to answer (I have 5 in total). There was a lecture where he showed us how to fix this, but I’ve been having the problem even after that up until being done with the entire quiz. Does anyone know how to fix this?

Hi Brogan,

Have you already tried to add Debug.Logs to your code to see what is going on during runtime? Maybe the first question gets ‘loaded’ but you don’t see that because the next question gets ‘loaded’ a few milliseconds later.

I am unable to get Debug.Log to work on any of my code, nor do I know where to put it.

Debug.Log was covered in the lecture where we wrote our very first code: ‘Set Up Visual Studio Code’. If you do not remember it, I would recommend to rewatch that video because Debug.Log is absolutely crucial, not just in this course but also if you want to develop your own games one day.

Use Debug.Log to figure out why the code uses two questions when the game starts. Since the computer just executes the code, the reason must be in the code. Maybe an if-condition is ‘wrong’, or a value is unexpected. Since the values get generated at runtime, it is impossible to tell what is going on just by reading the code. You need to know the values at runtime, and one way to get them is to log the values of variables into your console by using Debug.Log.

Privacy & Terms