- Home /
How to store enemies spawn schedule for each scene ?
Hi all,
I am creating a zombies shooting game, and this game has 10 kind of zombies , such as: zombie1 ,zombie2 ,..zombie10 . I want that each scene, GameController create 5 zombies and those zombies are created in a schedule (in order) such as:
scene 1: zombie1, zombie1, zombie2, zombie5, zombie5
scene 2: zombie2, zombie1, zombie2, zombie7, zombie7
scene 2: zombie2, zombie2, zombie2, zombie7, zombie7
I saw "plants vs zombies" can spawn zombies right time and in order but I do not know how to do.
The question is that,
How they do it ?
How can I save those schedules ?
Are there any kind data-structures to save those schedules ?
Thank everyone.
Answer by siaran · Apr 18, 2015 at 12:01 AM
You could just put a gameobject with a 'spawnenemies' script on it in each scene that spawns the correct enemies?
Hi Siaran,
thank your help. But if the game has 100 scenes, I have to make 100 scripts just for spawn enemies, So it is good but I want to find another way.
thanks.
No, you write just 1 script to spawn enemies, make a public array of enemies, then use that to instantiate. Like
public class Spawner : $$anonymous$$onoBehaviour {
public GameObject[] enemiesThisLevel;
void Start(){
for(int i = 0; i < enemiesThisLevel.length; i++){
Instantiate(enemiesThisLevel[i]);
}
}
}
You can use the same script in every scene. (This is a very simple one that doesn't take care of spawn positions or anything, but the point is - you really only need to write 1 script).
Your answer
Follow this Question
Related Questions
How to spawn enemy? (Enemies) 1 Answer
Help? Im trying to get my zombie prefab to spawn, but stop them spawning after a set spawn limit. 1 Answer
Spawn help? 0 Answers
Zombie Wave Spawning script 1 Answer
Enemy spawn 1 Answer