- Home /
Spawning Zombies Different Rounds
Ok so i wanna make a zombie game kinda of like in CoD black ops. So i want the zombies to spawn in only the room the player is in. So say in room 1 and the other doors are closed right, so the zombies only spawn in that room. Once you open a door zombies can spawn from the room as well. And for each round the numbers increase like round 1 there are only 10 zombies round 2 20 zombies and in round 3 is 30. So for each round multiply by 10. So i need help with that please. Dont say go to the forums or telling me to put down a script. If you would like to help more your name will be in the credits.
Answer by roamcel · Sep 23, 2011 at 04:57 AM
Not quite clear what you're asking. But if you need an outline, here it is:
 - create an enemy spawn script with a public parameter 'round' and a private parameter 'zombiesperround'
  - attach the enemy spawn script to an empty gameobject in your zone
  - create an empty gameobject (call it zonespawn) and place it in your zone.
  - attach a zone wide trigger or another proper trigger (like 'dooropen') to zonespawn.
  - attach the enemy spawn script to zonespawn
  - use OnTriggerEnter in zonespawn to call your enemy spawn script.
Voila.
Answer by wienerdog · May 05, 2013 at 11:17 PM
I times zombies per round * round so part of code not completely working spawns 55 zombies for some reason. var zombiePrefab : GameObject; var zombieSpawned : int; var player : GameObject; var spawn : boolean; var minWait : int; var maxWait : int; var waitTime : int; var zombiesperround : int = 3; var round : int = 1; var roundclock : GUIText;
 function Start () 
 {
     minWait = 60;
     maxWait = 120;
     waitTime = Random.Range(minWait, maxWait);
     spawn = true;
 }
 
 function Update () 
 {
 roundclock.text = ""+round;
 zombiesperround = zombiesperround * round;
     if(spawn)
     {
         Spawn();
     }
 }
 function Spawn ()
 {
 if (zombiesperround > 0)
     {
         yield WaitForSeconds(1);
         Instantiate(zombiePrefab, transform.position, transform.rotation);
         zombieSpawned +=1;
         zombiesperround --;
         waitspawn();
     }
 else
     {
     if (zombieSpawned == 0)
         {
             round ++;
             spawn = false;
             SetSpawn();
         }
     }
 }
 function SetSpawn ()
 {
     yield WaitForSeconds(waitTime);
     spawn = true;
 }
 function NewWaitTime()
 {
 waitTime = Random.Range(minWait, maxWait);
 }
 function waitspawn()
 {
     yield WaitForSeconds(1);
     spawn = true;
 }
Your answer
 
 
             Follow this Question
Related Questions
How do I spawn a random prefab? 1 Answer
Script needs fixing ?! 1 Answer
Why not can't spawn the object? 1 Answer
Slender pages collection does not activate gameobject I want 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                