Endless Loop....

Im attempting to create a state based turn mechanic but my thought was to use a while loop with Game Over as the breakpoint. However when i try to compile i get an endless loop detected… maybe im missing something but of course its a loop thats the point but as soon as Game over is true then its not… i dont know what they need from me here.

Organize your Sequence node so we can actually read the proper order. It’s too clustered to determine outright.

Also, Then 5 WHILE is not the correct. There’s nothing to LOOP.
A branch prior to the function call would be better.

Is Game Over?:

  • True → End the Game
  • False → Call the function

The sequence is irrelevant. It works as intended. I just hooked that into it. I was getting the same error when the while loop was the only code in the BP.

Game Over is False by default. That is why I have a NOT so that it resolves true for the loop. i havent added the code for the branches of the loop because theres no point if this starting point isnt going to work. Im just confused as to why it would be an endless loop. i have a clearly defined boolean for when it will be not endless…

What’s the exact error code?

I took the Sequence out for clarity

Usually I just implement features as needed for the desired result but this is my first attempt at designing towards a framework i have in mind and its been problematic. if you have another way to accomplish this state based turn feature im open to suggestions this just seemed like the obvious solution to me but i was clearly mistaken.

Event Begin Play only fires once, so overall I’m not sure why the code you showed was even there.

The code shown isn’t, or shouldn’t be the issue. You could probably disconnect the Begin Play and get there error. What’s shown isn’t from what I can tell from the limited error info what’s being pointed to.


For turn based you want a Function/Event that evaluates after each turn whether the game is over or not.

Player 1 has turn → Evaluate → If Game Over → End Game }ELSE{ Set Player to Turn.

i assumed having a loop on event play that didnt end until the game was over would make it firing only once irrelevant. The rest of the game runs great. its only when i hook in that portion that i get any kind of error.

returns no error(s) on my end, until its true.

Maybe its the NOT boolean im using then. is it not doing what i intended? My assumption is Game over is false by default so i need to use NOT to evaluate it to true to keep the loop going until it isnt

The NOT (when value is false) executes the Loop Body.

Because it stays true the loop cannot end.

Here’s the While Loop macro

You can see as long as the Condition evaluates to true it will loop.

i cant believe im not getting this but isnt that the intended functionality of a while loop to loop your code endlessly while its true? its frustrating i feel like i have a pretty good grasp of everything but this simple thing is eluding me. Here is my Get Tiles function for reference.

In a classical sense yeah. But there’s usually a way to change the condition inside the loop body.

This runs with zero issue. False by default, runs the loop body. We set TRUE when we reach 10. Loop Ends.

The while Macro is technically looking for a FALSE condition to be completed.

That fixed it actually… i hope i dont have to actually physically have the the set game over to true in the body of the loop. the loop is only really concerned with directing turn flow not what happens during the turns necessarily.

I wouldn’t use the loop at all. Like I said previously I’d structure the flow to call an Evaluation function or event after each player has committed a turn.

The Evaluation function/event determines if the game is over or not. On true it calls an event that actually ends the game. Otherwise it “sets” the next players turn and the game proceeds.

How do I define what a turn looks like then? in my limited experience i saw it as that loop where the turn begins and youre in the play tiles state which defines functionality and then you move to scoring then possibly swapping and finally getting new tiles and passing the turn. ive clearly never done turns before and with all the great tutorials out there i couldnt really find much.

How are you committing the inputs of the player?

At the end of that Logic flow I’d say the turn was over.

That sounds exactly like something I’d say. In a vacuum every function needed to physically manipulate game pieces and score them is there, but it’s not structured at all. atm I just have a button that will score your word and one to swap tiles, but they don’t lead anywhere it just performs the function as designed and then that’s it. that’s why I was trying to get it all pieced together with that loop. that’s my toxic developer trait. I start building and then when I need more functionality, I add it but then I have this hodgepodge of specialized functions but no way to really direct traffic so to speak.

I’m assuming swapping tiles counts as a turn. So I’d say On Score or Swap → End turn.