Hey. I'm currently creating a zombie game... I'm done with pretty much all the models and so on... but I can't get the zombier to spawn over and over again on a spot in my game.
I want it to spawn every 4 second...
Hey. I'm currently creating a zombie game... I'm done with pretty much all the models and so on... but I can't get the zombier to spawn over and over again on a spot in my game.
I want it to spawn every 4 second...
For recurring tasks, use InvokeRepeating. It saves you the trouble of maintaining your own timers.
var zombiePrefab : GameObject;
InvokeRepeating("SpawnZombie", 4, 4);
function SpawnZombie() {
Instantiate(zombiePrefab, transform.position, transform.rotation);
}
private float timer;
private float timerMax = 4; //sekunds befofe each spawn
void Update(){
timer += 1 * Time.deltaTime;
if(timer >= timerMax){
timer = 0;
//spawn zombie
}
}