Loops in blueprints vs. C++

So, perhaps this is a strange question, but how do you know the end of a loop in blueprints? In code, it’s easy because the brackets close. But for those of us new to visual scripting, I’m struggling to read these loops.

For example, take a loop that does the following:
Say there is a function. In that function…

  1. There is a macro that spawns a bunch of objects at a specified set of (X,Y) coordinates. (this is the start of the loop where an object spawns for each x and then for each y).
  2. The macro ends and outside the macro, blueprints changes color of each of the objects with index 0 to i.
  3. Then there is another function that maybe moves the objects around or resizes them.
  4. Then the function ends and returns to the construction script.

When does the loop end? When are the commands no longer applied to each separate object, but rather to the last object in the index list? When it leaves the macro (step 2)? When it can’t apply the commands to all items in the loop (say step 3)? When it leaves the function (step 4)?

This is simply a hypothetical example, it’s not an actual code (so please no comments on better ways to do the above). It is simply an example designed to inquire about the nature of loops in visual scripting. Is there a node / command to end a loop (no break it, but stop it from applying to commands from here on)?

I’m so confused.

Think of everything out of the Loop Body the same as inside { }.

When complete, flow continues out of the Completed exec.

Ha, that helps a great deal. Fabulous.

1 Like