Can i change the max loop iteration count at runtime?

hi everyone

maybe someone know if I can, and how to change the max loop iteration count at runtime using blueprints? if not can it be done by c++ , or you can only change it in the project setting in the editor?

thanks in advance

leo

You can set two Int variables, set the first one to 0, and the second to whatever number you need; inrement the first Int every time a loop executes, and check its value against the second before the next iteration. And you can change the second Int whenever you want, at runtime included.


If you mean the ForLoop, it’s the same, feed the Int to the Last Index, and you can change that at will.

thanks tuerer

thanks for your help, and I am sure it will work, but I need some way to manipulate the max loop iteration count because I have a complex code with a loot of forloop and that’s mean I will have to change the all code. I will do it but I thought maybe there is a simple way to change it at runtime.

again thanks for your help

leo

hi tuerer

I think I have not explained myself well enough, I’ll try to give you a little more details.

my project start with a creation of a grid(consist of locations, edges, ect…), to generate a large grid I encounter an error, in order to fix it I need to go to the project settings and change the max loop iteration count from 1,000,000(the engine Default) to much Higher values.

but I need the Higher values only to be a the beginning (when I generate the grid), after that I want to go back to the engine Default of 1,000,000.

so that way i have looked for a way to change the max loop iteration count at runtime. hope it make sense

thanks again

leo

Frankly, I don’t think it’s possible. For Loop is a standard macro that always takes in those input values.

Are you saying that you use lots of For Loops with manually entered values? Can you describe at least one example where you need to use the For Loop and change the number of iterations back at forth?