Hi, I try to simulate time and want to add 10 minutes every few seconds, but the programm doesn’t wait for the amount of seconds and just repeats the script like every millisecond.
Here is my Code thank you for helping.
IEnumerator CalculateTime()
{
if (TimeSwitch == false)
{
TimeMinutes += 10;
if (TimeMinutes >= 60)
{
TimeMinutes = 0;
TimeHours += 1;
}
TTime.text = TimeHours.ToString() + ":" + TimeMinutes.ToString();
}
if (TimeHours == 20 && TimeSwitch == false)
{
TimeSwitch = true;
Debug.Log("END");
}
yield return new WaitForSeconds(5);
Debug.Log("Wait");
}