- Home /
Duplicate Question
Zombie wave spawn help?
Hello, im a novice at coding, and am needing a little help with waves of zombies spawning in my scene. So i have multiple spawn points in my scene and i want on wave 1 for example to spawn 5 zombies, but i want them to spawn at the spawn points randomly, maybe 2 spawning at one point and 1 at another ect.... And i have an audio sound that i would like to play when the wave is complete. Below are some of my variables, if anyone can help it would be much appreciated.
var zombiePrefab : GameObject;
var zombiesSpawned : int;
var spawnPointOne : GameObject;
var spawnPointTwo : GameObject;
var spawnPointThree : GameObject;
var spawnPointFour : GameObject;
var spawnPointFive : GameObject;
var spawnPointSix : GameObject;
var spawnPointSeven : GameObject;
var spawnPointEight : GameObject;
var spawnPointNine : GameObject;
var spawnPointTen : GameObject;
Solutions to this specific and similar problems have been posted many times. You need to create an array of game objects rather than individual game objects. Then you can shuffle the array and pick the first 5. Google “Unity3d shuffle spawn”. Here is one link to a post about shuffling:
http://answers.unity3d.com/questions/345471/fisheryates-shuffle.html
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Spawn help? 0 Answers
Zombie Wave Spawning script 1 Answer
Mob spawn and start comming to me 1 Answer
Object Disappears on Start 0 Answers