Strange Bug: Progress Bar starts at value 2 when click Play Again Button

When i click the “Play again” button, progress bar already starts at position two, as for some reason already two questions will be removed when i click replay, see DebugLog of question count.

Shouldn’t the scene behave exactly the same no matter if i click play or reload the scene later? Isn’t everything resetted basically at the end?

I tried to copy paste the quiz and timer script from the repo but that didn’t work either. Is this some unity setting?

Thanks!

QM

1 Like

You may have a race condition. I believe GameManager should execute before Timer (and my tests confirmed it). You can go to the ‘Project Settings’ under the ‘Edit’ menu, find ‘Script Execution Order’, add the GameManager to the list, and move it up a bit. Do the same with the Timer but put it underneath GameManager

2 Likes

Thank you so much! This indeed solved the problem. As I’m quite new to unity i’m trying to understand why this only happened on my end and what was done differently in the course to prevent this.

Also how did you approach finding out which script has to come first?

I added DebugLogs for all Awakes and found out that apparantly the issue happened when Quiz Awake was before Timer Awake. Game Manager seems less important.

Further debugging showed that loadNextQuestion from timer seems to start as “true” although it is initialized as false. During Timer Awaker loadNextQuestion is already true which i don’t understand.

Currently i can solve the problems by just adding the Timer script to the execution order which leads it to beeing executed before the Quiz.

1 Like

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

Privacy & Terms