using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TimerScript : MonoBehaviour
{
[SerializeField] float timeToAnsweringQuestion;
[SerializeField] float timeToShowCorrectAnswer;
public bool isAnsweringQuestion; //DEFAULT bool is false;
float timerValue;
void Update()
{
TimerCountingUpOrDown();
}
private void TimerCountingUpOrDown()
{
timerValue -= Time.deltaTime;
if (isAnsweringQuestion) // if why it didnt get executed firsy?, the default value is false,right?
{
if(timerValue <= 0)
{
isAnsweringQuestion = false;
timerValue = timeToShowCorrectAnswer;
}
}
else
{ if (timerValue <= 0)
{
isAnsweringQuestion = true; //but after isAnsweringQuestion set to true,it execute the if Block
timerValue = timeToAnsweringQuestion; ///////////////////////////////////////////////////////////////////
}
}
Debug.Log(timerValue);
}
}
but if i set āif (isAnsweringQuestion==true)ā, the script work normally, if i set āif (isAnsweringQuestion==false)ā, it will loop to only on timeToShowCorrectAnswer
but it never stated that if (isAnsweringQuestion) is either true or false. in fact by defau,lt, and according to this course, if (isAnsweringQuestion) is equal to (isAnsweringQuestion==false)"
so why it excute as if it was written āif (isAnsweringQuestion==true)ā? it never stated in the scrip. im never been this conffused in this course until now. please help!