Infinite Loop Error

I’m making a simple block building game where you can save and load different worlds.

My problem occurs when loading into a world. Usually it loads everything in fine, but after it has to load in roughly 2,000 blocks, I get the error displayed below.

Screenshot (1452)

Below is my load game set up

Screenshot (1450)

Screenshot (1450)2335×1229 253 KB

Screenshot (1451)

Screenshot (1451)2327×1229 279 KB

this is just an editor limitation, you can change that in Project Settings → Engine → General Settings → Max Loop Iteration Count.

but its better to split it across multiple frames. ie instead of ForEach Loop do a For loop 0-100, delay one frame and repeat until empty

1 Like

Sorry, I’m kinda new and I’m having some trouble understanding what you mean with the for loop solution, could you maybe show me an example so that I know I’m doing it correctly?

something along these lines, havent used it myself before but you should get the idea which is basically you’re splitting the work across frames

Thank you for your help! One last question, how do I get the Array Element for Actor Class in this solution?

The above solution is somewhat like lazy loading method, It will spawn a 100 actors and then have a delay of tick and then will do it again.
To get integrate this solution in your logic you have to split the saved Classes array you are using. You have to take first 100 elements of the array then follow the above solution. Make sure to update the Start Index properly and you can use the index to get the class from the array and spawn the actor only when the index is valid

Here is what I have now

The infinite loop error seems to have stopped, but now I’m getting a bug where it spawns 3 times the amount of blocks it’s supposed to (it can load the first 100 fine)

just plug SavedClasses in the IsValidIndex and use Get(Index) on true

is it possible you have duplicates of the Blueprint? otherwise you’ll have to debug though it, maybe put a printstring on the Index and see if you get unexpected calls