Hello! I need a little help, i have a script that makes my enemies spawn in four positions, but they keep spawning forever and i need to have, for example, ten enemies in the first level and after you kill them all you move on to the next level. This is my code
public class TimedSpawn : MonoBehaviour {
public GameObject spawnee;
public bool stopSpawning;
public float spawnTime;
public float spawnDelay;
// Use this for initialization
void Start () {
InvokeRepeating ("SpawnObject", spawnTime, spawnDelay);
}
public void SpawnObject (){
Instantiate (spawnee, transform.position, transform.rotation);
if (stopSpawning) {
CancelInvoke ("SpawnObject");
}
}
}
↧