Y
Y
yraiv2022-02-23 15:32:06
Unity
yraiv, 2022-02-23 15:32:06

Why is the timer not working?

What's wrong?

IEnumerator SpawnMobs()
    {
        Debug.Log(ThisZombieSpawn);
        Debug.Log(CountZombieSpawn);

    if (ThisZombieSpawn < CountZombieSpawn)
    {
         Instantiate(ZombieType[NomberZombie], StartPos.position, Quaternion.identity);           
         yield return new WaitForSeconds(4); // доходит до сюда и дальше тишина... 
          ThisZombieSpawn++;
         SpawnMobs();

    }

    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LittleBob, 2022-02-23
@yraiv

In the start method or wherever you need it, you most likely did not write StartCoroutine(SpawnMobs())

D
Dima Magas, 2022-02-23
@White_Night

Should it be a looped coroutine?
At the end, do you call the SpawnMobs method, or did you mistakenly decide to start the coroutine again?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question