Download

New to BP. How would you do a NESTED FOR LOOP?

Hi. Very new to UE4 and BP but not to coding. In C# to create a nested FOR LOOP I would code something like this


for ( i = 0; i < 10; I ++ )
{
   for ( j = 0; j < 10; j ++)
   {
      PERFORM SOME ACTION
   }
   PERFORM OTHER ACTION
}

However, I’ve no idea how you would do this in BP.

Also, how would you get the equivelent of the I and J variable from a BP FOR LOOP, when you don’t actually use a variable in BP loops? For example, in Unity, if I wanted to instantiate an object at the objects X transform position + 1000 * i and Y transform position + 1000 * J. Again in C# (Unity) it would be something like


instantiate(gameobject, new vector3(transform.posistion.x + 1000 * i , transform.position.y + 1000 * j, transform.position.z, quaternion.identity);

As you can see, you can take the variable from the loop directly and apply it to the instatiation. With no variable declaration in a BP for loop, how would you go about this?

Any help appreciated.

It’s pretty obvious when you look at the nodes a bit, literally just plug a for loop into a for loop:

Hi,

I hope this will help you a bit:
99b5bdb9430424367a5b3df3566448e36a97141f.jpeg

EDIT:

Sorry, I haven’t noticed that someone has already posted a solution for you!

Thanks. It it pretty intuitive when you see it. I just couldn’t rap my head around it visually. Thanks again.