Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Limit spawn number

$
0
0
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"); } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>