- Home /
Zombie Spawner script
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...
why you don't use enemy.position = Vector3.$$anonymous$$oveTowards(enemy.position,waypoint,position,Time.deltaTime * speed); but maybe you will get the problem that zombie sometimes goes and stuck with a wall
@Uriel, did you even read his question? :) He doesn't want to move zombies, he want to spawn zombies.
In case he was a she, I apologize. Then she want to spawn zombies :)
Oh yeah your right, I apologize for putting a foolish comment :P, I don't read it to well
Answer by Victor 1 · Apr 17, 2011 at 11:18 PM
private float timer; private float timerMax = 4; //sekunds befofe each spawn
void Update(){ timer += 1 * Time.deltaTime; if(timer >= timerMax){ timer = 0; //spawn zombie } }
Answer by Statement · Apr 17, 2011 at 11:34 PM
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); }
Your answer
Follow this Question
Related Questions
Zombie attack script help 1 Answer
Damage trigger? 1 Answer
Losing hp 1 Answer
How do i make zombies? 2 Answers
Enemy walking above ground 1 Answer