using System.Collections; using System.Collections.Generic; using UnityEngine; public class Spawner : MonoBehaviour { public GameObject enemyPrefab; public int numEnemiesPerSpawn = 1; public float StartDelay = 1f; public float timeBetweenSpawns = 1f; public int totalEnemies = 1; float timer = 0f; int counter = 0; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { timer += Time.fixedDeltaTime; if(timer > StartDelay && totalEnemies > counter) { for(int i = 0; i < numEnemiesPerSpawn; i++) { Instantiate(enemyPrefab, transform.position, Quaternion.identity); counter++; } timer = 0; } } }