Answer the question
In order to leave comments, you need to log in
How to restrict coroutine?
In my game, I use coroutine to spawn coins and medkits (health recovery) with this code:
IEnumerator Coin()
{
while (!Player.lose)
{
float newPos = a[new System.Random().Next(0, a.Length)];
Instantiate(coin, new Vector2(-11f, newPos), Quaternion.identity);
yield return new WaitForSeconds(time);
}
}
Answer the question
In order to leave comments, you need to log in
add to the beginning of WaitForSeconds?
Or not launch it right away.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question