- Home /
Zombie Spawn Per Round Script
So hey there im new here but i have a zombie game and i looking for a script that spawn zombies per round. in the left corner i want tho show round... can you help me?
Comment
Answer by Cherno · Oct 05, 2013 at 10:19 PM
var TurnNumber : int = 1;//keeps track of the turns :P
var SpawnPoint : Vector3;//enter the desired coordinates where the zombies should spawn here.
var ZombiePrefab : GameObject;//drag your prefab gameobject of a sample zombie here, it will be copied and instantiated into the scene
var ZombieClone : GameObject;//keep this empty, the script will fill it when a zombie is instantiated.
//It only holds the last spawned zombie, all before that one have to be accessed by some other method.
function Update()
{
if(Input.GetKeyDown(KeyCode.Space))
{
NextTurn();
}
}
function OnGUI()
{
GUI.Label (Rect (0, 0, 50, 100), "Turn " + TurnNumber);//displays the turn number in the upper left corner.
//GUI.Box (Rect (0, 0, 50, 100), TurnNumber);//if you want to see how the dimensions of the label above actually look, active this line of code (or just use it instead if you don't mind the box graphic)
}
function NextTurn()
{
TurnNumber ++;//increases the turnNumber value by 1.
SpawnZombie();//calls the function that spawns zombies.
}
function SpawnZombie()
{
ZombieClone = Instantiate(ZombiePrefab, SpawnPoint, Quaternion.identity);//Spawns a copy of ZombiePrefab at SpawnPoint with default rotation.
}
Hey Thx but i need a script there makes a new round when i have all zombies killed and a gui text have you this?
Answer by Tknoguyfication · Jan 11, 2014 at 11:35 PM
It's great, but all in one line. Could you please give a pastebucket link?
Your answer
![](https://koobas.hobune.stream/wayback/20220613115349im_/https://answers.unity.com/themes/thub/images/avi.jpg)