Hello, I don’t know if anybody has mentioned this issue before, but if you update the boolean “isComplete” only in the method “OnAnswerSelected” like in the video, then it won’t be updated if you just select nothing and wait until time runs out. The issue is not obvious except when you select nothing for the last question, where you can see that “isComplete” is not updated to have a value of true.
My solution is to create a method to update the boolean “isComplete”:
void UpdateCompleteStatus() {
if (progressBar.value == progressBar.maxValue)
{
isComplete = true;
}
}
and call it both when an answer is selected or when time is up:
public void OnAnswerSelected(int index)
{
hasAnsweredEarly = true;
DisplayAnswer(index);
SetButtonState(false);
timer.CancelTimer();
UpdateScoreText();
UpdateCompleteStatus();
}
void Update()
{
timerImage.fillAmount = timer.fillFraction;
if (timer.loadNextQuestion)
{
hasAnsweredEarly = false;
GetNextQuestion();
timer.loadNextQuestion = false;
}
else if (!hasAnsweredEarly && !timer.isAnsweringQuestion)
{
DisplayAnswer(-1);
SetButtonState(false);
UpdateScoreText();
UpdateCompleteStatus();
}
}
A similar issue also happens in a previous lecture when the code in the video only updates the score text when an answer is selected and not when time runs out. I hope these issues can be addressed in the videos, or we should bear in mind that the lectures do not always give a compete correct solution and we will need more careful debugging ourselves.