// Update is called once per frame void Update() { Vector2 currSpot; GameObject currZombie; float deltX; float deltY; if (ZombiesLeft > 0) { // time to spawn a new zombie if (Time.time > (lastSpawn + spawnFrequency)) { deltX = Random.Range(-spawnPointSize, spawnPointSize); deltY = Random.Range(-spawnPointSize, spawnPointSize); currSpot = new Vector2(spawnPoint.x + deltX, spawnPoint.y + deltY); currZombie = GAMESTATE.SpawnZombie(currSpot); ZombiesLeft -= 1; Zombies.Add(currZombie); lastSpawn = Time.time; } } }
// Update is called once per frame void Update() { if (ACTIVE_SPAWNER == true) { if (delt_time > spawnFrequency) { delt_time = 0; for (int i = 0; i < spawnNumber; i++) { if (totalSpawned <= spawnCap) { GAMESTATE.SpawnZombie(selectRandomPosition()); totalSpawned += 1; } else { ACTIVE_SPAWNER = false; } } } } delt_time += Time.deltaTime; }