Hey, I’m making a 2d game, which requires 6 prefabs which spawn enemies at specific intervals. But when there are some instances already in the game, when the prefab instantiates again, it makes 2 of the prefabs spawn, and on the third time 3 will spawn and so on. I have all of the prefabs above the screen, out of view. Here is the code on my prefabs:
var Enemy:Transform;
private var Timer:float;
function Awake() {
Timer = Time.time + 5;
}
function Update() {
if (Timer < Time.time) {
Instantiate(Enemy, new Vector3(-2.567029, -1.864899, -4.613899), transform.rotation);
Timer = Time.time + 5;
}
This is the code that spawns the enemies at certain times. Is there a way to stop the doubling up when they spawn? It means my points system is screwed up! Cheers