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?
var TurnNumber : int = 1;//keeps track of the turns
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.
}
It’s great, but all in one line. Could you please give a pastebucket link?