Why there are no BP WhileLoop With Break?

Hi.

Why there are no BP WhileLoop With Break?

http://s6.postimg.org/m8yh0a1rl/screenshot_119.png

Can your team add it?

a while loop is a loop with a break. you just change its conditional boolean to false to break it.

you can also use more than 1 boolean by using an And node, so one of the booleans could be called bKeepLooping, and you just set it to false to break out of the loop.

1 Like

Thank you!

Well, that’s not a break. It’s a condition to enter loop’s body.

A break statement terminates the current loop from inside of loop’s body and transfers program control to the statement following the terminated loop.

So, in this case a break statement would be a node that you call which would break out of the loop from inside of the loop’s body and then run the statement that goes from the Completed node. Here’s how it would look like:

What you propose is equivalent to this in the code:

while(MyCondition) {
    DoStuff();
}
DoOtherStuff();

And so there’s no break.

The question asks how to write this in blueprints:

while(MyCondition) {
    DoStuff();
    if(CollidingWithOtherCorals)
        break;
}
DoOtherStuff();

It appears Blueprints do miss the break statement.