large loops won't work

Hey everyone !

I run into some problem trying to use large loops in BP.

I create a new BP derived from actor.

Then i add the following construction script:

I get this:

It is stopping at 250 000, telling me i am over 1 000 000.

When inserting instructions in the loop, the breaking limit decreases (sort of randomly).

With lots of calculations, it can stop at ~ 40 000. But the message (1 000 000) is always the same.

Anything i shouldn’t do here ?

Cheers

Cedric

I am sure someone will correct me if I am wrong, but from what it looks like, you are doing this in a Construction Script, and there is no delay in there.

I am not exactly sure about why would you want to make an instantinous loop that goes for 300.000 times, but surely it’s not healthy and Unreal stops itself, thinking the same way.The loop you are trying to do is -instant-. Calling it so many times in one single frame isn’t practical and Engine takes it as a “runaway loop”.

You may want to construct this better, putting a delay between each loop for example.

Hey Achilleon,

I am making a procedural terrain.

This loop is the construction of the terrain in the BP.

The size of the loop depends on exposed variables (Imax * Jmax) and are set to small values when creating the BP, so no problem there.

Then, when the BP is all set, i can increase the values for a large terrain. The problem is that around 256x256 i run into those errors.

I do the same in c++ with no problem, and hence i know that the engine can handle a 512x512 terrain with no problem (want to make this a BP to share with a non c++ friend).

Cheers

Cedric

Try increase Edit->Project settings->General Settings Maximum Loop Iteration Count, maybe your loop will fit limit and don’t break engine;)

MaximumLoopIterationCount = FMath::Clamp( MaximumLoopIterationCount, 100, 10000000 );

Hey Pierdek,

That did the trick, thank you very much !

I tried to transform your comment into an answer but i messed up.

I don’t know if you can change your own comment into an answer, otherwise you can copy paste it into a new answer and i’ll marked it solved.

Thanks !

Cedric