WhileLoop issues

The loop condition is pretty much “Should I loop again?”.

The compiler is looking for a condition that can be changed in the while loop itself, within the loop body. You could try having a counter that increments each loop and manually sets the condition to false after X iterations. Here’s the thing though, loops in BP do not wait for the loop body to finish, they call one after the other with as little delay as possible -

I can’t confirm, but I believe loops in BP in general try to execute in-between frames, so it’s likely that the hard cap is reached well before the condition would ever be false. What may be better is just using a branch off of Tick - this is effectively a while loop except that it will iterate slower and can’t have an infinite loop. I looked at some of the screenshots you posted in slack, and I would most definitely have a branch off of tick with a do once node- that’d achieve the same result you seem to be trying for- so something like this-

Ran into a bit of a pickle it seems. There are two different issues; the first is pretty minor, the next one is, well, I’m baffled. I’ll report the issue and what I think might be going on?

First issue - WhileLoops are completed when the condition is false. This is… weird. Maybe its just me.

Second issue: When figuring out that the bool had to be false, I adjusted my level BP. I’m using an event dispatcher in an actor BP and calling the dispatcher in the level BP. During begin play, I then bind the event to a custom event. This custom event sets the bool to false. However, when I play in PIE, I am getting infinite loop errors.

In the actor BP, the dispatcher looks like this:

  • OnComponentHit → Call Custom Event (animation timeline… this works)… then call the dispatcher (TargetHit). This part works, as I’ve included a print string for debugging after the call.

In the level BP:

Begin Play → Several dispatcher bindings/events for scoring… this all works perfectly. Then after the scoring bindings, I then bind the “TargetHit” dispatcher to a “TargetHit” custom event (Also tried naming the event to “L_TargetHit” - same issue). This event sets the bIsTargetActive to false.

Now, when I attempt to use a WhileLoop with the bIsTargetActive condition, it runs into an infinite loop error. The only reason I can think of is that the BP compiler is not taking the bind event → custom event → set boolean into account.

Hi SaviorNT,

  • Can you show me a screenshot of your BP setup for the custom event and what is calling it?

  • Try running a print string on your boolean, do you ever see it change values?

  • Does this occur in a clean, blank project with no additional content or is it limited to one project?

  • What steps can I take to reproduce this error on my end?

Hi SaviorNT,

We have not heard from you in several days. I am marking this as answered for tracking purposes. If you are still experiencing this error, please comment with the requested information.