Where the Spawn Variable Lives

Hello!

This lecture I had things that I did very differently from Rick through the challenge. My main question is, I did not use a local variable for the AttackerSpawner to know when to start/stop spawning (GetSpawn() in this example)

IEnumerator Start()
{
    while (myLevelController.GetSpawn())
    {
        yield return new WaitForSeconds(Random.Range(minTimeBetweenSpawns, maxTimeBetweenSpawns));
        SpawnAttacker();
    }
}

This made it so I didn’t have multiple bools across my scripts waiting for the same thing to happen. Is there any disadvantage to doing it like this?

Thanks!

Hi,

Good job on challenging yourself. I don’t see any issue with your code, and if it works, it’s a solution by definition. :slight_smile:


See also:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms