Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

How to make the clones of a zombie continue to clone?

$
0
0
Basically I have a scrip to spawn zombies. I would like them to spawn in waves, but that is another story. My issue lies with the main zombie prfab. Whenever I run the game and I kill that first zombie. It no longer will make zombies. How do I fix it? #pragma strict ------variables start-------- var zombie : Transform; var clone : Transform; var zombiesSpawned : int; var zombies = 11; var player : GameObject; var spawn : boolean; var min : int; var max : int; var wait : int; var spawnPoints : Transform; var positions : Transform; ------variables end -------- // on start I set min and max, set spawn to true, and set a random number value function Start () { min = 1; max = 10; spawn = true; wait = Random.Range(min, max); } // Update I have an if statement that calls the function Spawn function Update () { if(spawn) { Spawn(); } } // The function Spawn is where I believe my issue lies. //This is where I make more zombies. function Spawn() { if(zombie) { Instantiate(zombie, transform.position, transform.rotation); zombies++; NewWaitTime(); spawn = false; SetSpawn(); } else { Instantiate(zombie, transform.position, transform.rotation); zombies++; NewWaitTime(); spawn = false; SetSpawn(); } } // a little extra if you can help why isn't it spawning more than one zombie? function SetSpawn() { if(zombiesSpawned == 0) { zombiesSpawned = (zombies + 12); } yield WaitForSeconds(wait); spawn = true; } function NewWaitTime() { wait = Random.Range(min, max); }

Viewing all articles
Browse latest Browse all 508

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>