- Home /
Can't find the bug in my timer script. . .
Hey I'm new to coding and set this up to reset a game object after it was finished with it's animation. It works twice then fails to reset again. public float delayTime; public float resetTime; // Use this for initialization void Awake () { StartCoroutine (Go ()); }
IEnumerator Go()
{
while(true)
{
yield return new WaitForSeconds(delayTime);
delayTime = resetTime;
gameObject.SetActive(false);
}
}
Comment
Answer by alemimi · Jan 03, 2015 at 03:02 PM
I'm sure it's because of the while(true), that means "forever" so the script gets stuck in an endless loop, and i don't see why would you need it anyway since it is located in the "Awake" method... Try removing it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613175459im_/https://answers.unity.com/themes/thub/images/avi.jpg)