Quick Question About Delay Inside a Loop

Hey there :slight_smile: just a quick question.

is it possible to have a delay inside a loop (inside a function) ?

I explain, I created a spawner that can spawn a random number of items at random positions in a defined range, it works well but with many items it can impact the performance. I would like to have a slight delay of 0.1 between the spawn of each item.

how can I do it?

ps: sorry if my english sounds bad, it’s not my native language.

by default its not something that can be done with a standard loop since a loop basically stops execution of all things until it completes( theres a vid in the beginner series of unreal youtube). people will say that you can go in and modify the base logic of the loop but its really not needed. you can simply make your own custom loop. for the basic idea on this you simply create a event then have a branch, the bool of the branch you will connect to a int greater than node. if the branch is false you run the spawn script, a delay, increment the int, then call the event again. once the branch is true you know the loop is done.

Good answer. I also noticed others attempting to create a for each loop with delay. I always use a similar method to what you exemplify above.

thank you for your quick reply. yeah now it makes sense.
That’s exactly what I wanted to know, thanks again! :slight_smile: