I need help to delay loop

Hello, I’m making grid based procedural dungeon.

so i did many forloops, consecutive forloops easily trigger infinity loops detection. so i did search.

i found that all loops execute in 1 frame. ok UE4 can think it’s infinty (because it’s more than 100000 loop total)

so someone said delay (0) node make process delay 1 frame. so i did place delay node. but problem is

1.delay seems ruin forloops, doesn’t iterate properly( all works destroyed) is it?

2.if so, is there alternative way to delay process? i need to process through multiple frame to avoid infinity loop detection

Thank you!

thank you for answer, i will give it a try!

have good day!

Delay in loops is a no-no.

Your best bet is probably to build delayed for loops yourself from scratch. It’s less complicated than it sounds. A for loop is very simple, it’s just incrementing a (local) variable and repeatedly executing a branch of instructions.

Instead, make that variable global and use Tick or Timer to execute & increment.

Here is an example with a main loop with i going from 0 to 100, and an inner loop with J going from i to 200. The main loop adds a frame between each iteration, while inner loops executes 5 per frame.