Hello all! I have a spawning system that checks the maximum spawn limit by randomising between two locations and if its below it, it will spawn more zombies.
At the moment it all works good except and the start of the game as it starts spawning it spawns the zombies at the random locations however all at once which makes them explode (which does look pretty cool) but its not what I want. So I inserted a delay using
however it only seems to run the delay code once then never again so it waits for 5 seconds, then spawns the exploding zombies. This is my code;
I have also tried using LateFunction but no luck how can I make it run the code more than once? thank you!
In the end I still don't know why the yield function doesn't work, so instead I created a small timer
and a boolean
and then put in
answered Jun 18 '12 at 05:42 AM
I'm not entirely certain how Coroutines behave in UnityScript, but I'm pretty sure that your call to
I think the easy fix is to just insert the yield keyword before your call, compare to the documentation page. Also, you need to move the counter increment before the call to Delay, so it registers as "a zombie will be spawned", and prevents you from indefinitely spawning zombies until after the delay (because your counter would remain 0 the whole time). Move "randomGens" after the delay, for a similar reason - otherwise locationToSpawn might change in the meantime, overwriting the value for all zombies that are still in the "spawn queue".
answered Jun 17 '12 at 07:48 PM