I’m having an infinite loop error in my endless runner game

I don’t know why

well the game is “endless”, and maybe the engine mistook “endless” for “infinite”…
it is very difficult to help unless we have something to look at.

  • for blueprints the Editor should be indicating the blueprint and probably the event that is doing infinite loop or infinite recursion,
    • if an “infinite loop” is intended (the thing restarts as soon as it finishes) then insert a Delay(0.1) before the exec line going back to the start of the execution path, but just be forewarned that infinite loops should have some conditional to get out of somewhere.
    • if the thing is absolutely running 100% of the objects existence, then PLEASE consider Tick() it is right there, and it does that already (the problems with it come from number of objects use it, and doing too much inside it)
  • for C++ the crash report should include a call stack trace where you look for the function that is being called the most in the trace, and in your IDE do a “Find All References” to see what is calling the function.
  • alternatively in C++ if it is an actual loop that is doing this then you will need to look at the last function in the call stack trace

It usually happens when a while loop doesn’t have an exit condition, or when two functions call each other.

Welcome to the community, @DigpromGameStudi! :waving_hand:
Infinite loop errors can definitely be frustrating — and in endless runners, they often sneak in when spawning tiles or moving actors based on tick/update events.

:magnifying_glass_tilted_left: A few quick things to check:

  • Look for Event Tick or OnOverlap logic that might be calling the same function repeatedly without a delay or condition.
  • If you’re spawning tiles, make sure you’re not recursively triggering another spawn without a stop condition (like a tile counter or max distance).
  • In Blueprints, you can enable “Show Execution Flow” while debugging — super helpful to trace what’s looping.

:brain: Bonus Tip:

When bugs like this pop up (especially logic-related ones tied to assets like your track pieces), it’s easy to forget which ones you’ve tested or fixed — especially if you’re experimenting a lot.

That’s part of why we built Asset Optics — a plugin that lets you:

  • :pushpin: Add notes directly to Blueprints or tiles like “check for spawn loop here”
  • :white_check_mark: Create checklists for debugging steps (like “added delay”, “confirmed spawn condition”)
  • :counterclockwise_arrows_button: Sync your notes to a dashboard so you don’t lose track as the project grows

Might not fix the loop directly — but it helps avoid reintroducing it later when you’re deep into polish.

Let us know if you can share a screenshot or describe what the loop does — happy to help you track it down! :rocket:

LOL… You Make My Day!! :rofl:

Do not do this:

Example1: (Recursive)

void MyFunction()
{
      MyFunction();
}

Example2: (while → No exit condition)

while(true)
{

}

Example3: (for → wrong limits)

for(int i=0;  i>-1;  i++)
{

}

Example4: (goto → No exit condition) → same as stream flow in blueprints

void MyFunction()
{
      label:

      goto label;
}

Using GoTo is very bad pactice… if you use goto probably you have a bad desing

1 Like