hello I have a problem and i dont know how to make it. For school we need to create an sideshooter. We have done anything except the enemy waves. We have 10 enemy's. And what i want to do is have a script. that you can set the waves into with like 4 spawnpoint in it that it randomly spawns in. but you can also add more enemy's per wave. and that you can also add more waves. Because we need like 20 waves. Does someone has a script for that because i dont know where to start? hope you guys can help
Code (CSharp): public List<GameObject> enemies = new List<GameObject>(); // my list of baddies public List<Transform> spawnPoints = new List<Transform>(); // my list of spawn points public int wave = 1; // start at wave 1 presumably private int enemiesSpawnedThisWave = 0; private int enemyTotalThisWave = 0; public int baseEnemyCount = 3; // base enemy amount public int additionalEnemies = 10; // extra enemies per wave public float timeBetweenWaves = 5.0f; // 5 sec public float timeBetweenSpawns = 0.5f; // half sec void Start(){ Invoke("StartWave", timeBetweenWaves); } void StartWave(){ enemyTotalThisWave = baseEnemyCount + (wave * additionalEnemies); // add any variation here to spice it up InvokeRepeating("Spawn", timeBetweenSpawns); } void Spawn(){ // your spawn code(instantiate / pool system // use random range to pick random enemy / spawn point enemiesSpawnedThisWave++; if(enemiesSpawnedThisWave >= enemyTotalThisWave){ CancelInvoke("Spawn"); wave++; enemiesSpawnedThisWave = 0; Invoke("StartWave", timeBetweenWaves); } } very basic implementation all written in the browser so be aware it may contain an error or 2... but is meant to be more of a guide anyway...
Thanks you so much i will take a look at it. In your code it says pool system. what do you mean with that? And in what script do you putt this because i think it isnt't C# because you dont have public class monobehaviour?
Do a search on pools you'll see plenty... basically a recycling system ratyer than create / destroy. This is c# but not a full class definition so no inheriting from monobehaviour... these could be integrated into your current spawning class or used to start a new one. I just wanted to show one possible way to do what you were looking to do.