Spawning actors after a delay

321boo

  • Posts: 5
Hi,

I'm looking to spawn a random number of actors one at a time after a delay of 2-5 seconds for each actor.

E.g. spawn-> 2 secs-> spawn-> 3.5 sec-> spawn-> 5 secs -> spawn...

My current code makes a random number of actors spawn all at the same time after a delay. Does anyone have any ideas??

Luyren

  • *
  • Posts: 2291
You have to multiply your "do after" time by the current loop count. You could still have problems with the random generation though, as it would generate a different number each time, so I recommend you use a manual timer instead for full control of it, explained here: https://youtu.be/8A3mmm32l6g

You'd just need to add a number attribute to count the amount of cycles, and stop it when it reaches your maximum number of cycles.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

321boo

  • Posts: 5
Hi Luyren,

Could you please give me more detail on what you mean by "multiply your "do after" time by the current loop count"?

I watched your link and I'll defs be giving the manual timer a shot. Thanks heaps!!

Luyren

  • *
  • Posts: 2291
Look at your screenshot. You have a do after block generating a random number between 2 and 5. Above that, you have the repeat block, and at the end of it there's a "current loop count" green block. You can grab that and use it as a number block. So grab that and multiply it by the random number in the "do after" block.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

321boo

  • Posts: 5
You're a legend, thank you!!