- Home /
Zombie Wave Spawning
Im a novice unity user. Im trying to make a game where there are waves of zombies that spawn from random locations once the previous wave is finished (all the zombies are gone). I think I need to use the Instantiate command, but i cant be sure. I have a prefab called "Zombie" that i want to spawn. Thanks in advance!
Answer by hvilela · Dec 04, 2012 at 06:32 PM
Check the Instantiate documentation. The first example shows how to "spawn" 10 objects.
I read the documentation, but I am not sure how to edit it. I used my zombie prefab, and it kept spawning them without stopping.
Then provide a snippet of your code, it's hard to help without being able to see what might have been written incorrectly
Never $$anonymous$$d, got it. All i had to do was add some extra variables.
pragma strict
var prefab : Transform;
var zombie: int;
var wave : int;
var zombienum : int;
function Start () {
wave = 1;
zombienum = 5;
zombie = 0;
}
function Update () {
if(zombie < zombienum) {
Instantiate (prefab, transform.position, Quaternion.identity);
zombie += 1;
WaitForSeconds(2);
}
}
Your answer
Follow this Question
Related Questions
Spawn help? 0 Answers
Coroutine for zombie spawner not working, any help apreciated 2 Answers
Zombie Spawner script 2 Answers
Points - Kills fps 1 Answer
beginner needs AI help 2 Answers