Infinite loop in branch? Infinite loop error bug

This is not a bug. If you trigger the infinite loop error you get the callstack that was executing whenever the runaway threshold was reached. Depending on what happens in your game, what other actors are present etc. this may not always be the exact same location. However it should more or less trigger in a place that is most frequently executing (i.e. has the highest probability to be executing when the limit is reached).

I explained some of the technical details under the hood in this thread here which also contains a few potential solutions. With the CellsToCheck you seem to have an array variable already so your’s isn’t exactly the same problem but most should still be applicable.

With the Loop until the queue is empty you should already be mostly setup to early out from the loop even before the queue is empty based on a simple maximum number of entries to process per call. Then you can just continue the next tick until the queue is actually empty by simply calling the function again.

1 Like