Zombie Wave Spawning?
Currently attempting to make zombies spawn in waves. I am using script found at http://wiki.unity3d.com/index.php?title=Enemy_Spawner I understand how the spawning of a wave works however when implemented to multiple spawn locations the script becomes useless because the zombies will keep spawning at the same location because it only applies to a single spawner and not the entire game.
Is there a way to reference each spawner and make zombies spawn at those locations? Also, is there a way to implement a wave counting system, one which can track all zombies killed rather than those relating to that specific spawner?
Answer by Oliver-Bogdan · Oct 19, 2016 at 03:17 PM
You can use only one instance of the spawner and create a list of spawning position that are stored in an array (or a List)
You can modify spawnEnemy method so that it uses a random spawn position.
private void spawnEnemy()
{
GameObject Enemy = (GameObject)Instantiate(Enemies[enemyLevel], GetRandomSpawnPoint(), Quaternion.identity);
Enemy.SendMessage("setName", SpawnID);
// Increase the total number of enemies spawned and the number of spawned enemies
numEnemy++;
spawnedEnemy++;
}
private Vector3 GetRandomSpawnPoint(){
// here you would choose a position of a random (or not) Spawn Point and return it;
//select a random SpawnPoint from a list and return it's position
//you can fiddle with this so that maybe you could sequentially traverse all spawn points rather than choosing a random one each time.
}
For tracking all the zombies that were killed I suggest you let this video inspire you.
https://unity3d.com/learn/tutorials/topics/scripting/events-creating-simple-messaging-system
Can you please elaborate on the GetRandomSpawnPoint() function. I am relatively new to C# and I can't find a definite way to create the appropriate list. I also can't load the recommended tutorial due to network blocking.
How would I set the list up? and return a random value for that list
Your answer
Follow this Question
Related Questions
Enemy Spawner Crash 1 Answer
[SOLVED]Multiple enemies Wave Spawner 1 Answer
How to make an array that stores x, y and z co-ordinates? 1 Answer
Spawning Bug. 1 Answer
NetworkServer.SpawnWithClientAuthority not working? 1 Answer