Download

Every Combination of a Set of Floats to Create Vectors?

Hi everyone, I am currently trying to make a tool for my game which requires an array of vectors.

To create this array I have a bunch of X values (e.g. 0, 1, 2), a bunch of Y values (e.g. 0, 1, 2) and a bunch of Z values (e.g. 0, 1, 2).

If I combined all of these values in every possible combination I would end up with a set of 27 unique vectors. If I plotted these vector points on a 3-axis coordinates grid it would show a cube-like array of points, with the furthest point from the origin being (2, 2, 2).

My question is; if I have all of these X, Y & Z values, how can I work out all 27 of the points using UE4 blueprints.

Any help is much appreciated as I am completely lost at this point.

Thank you.

you need to use 3 nested loops, something like this:

.for x in “all x values”:
. for y in “all y values”:
. for z in “all z values”:
. vector = make_Vector(x,y,z)

Blueprint:
40901718c5717147b7fb02b7929cdb84e96185ae.jpeg

This works perfectly, thanks!

Sorry to interupt this thread, would that work, this method wouldnt generate all values would it?

For example it would not generate something like 1,4,2 because it only cycles through the loop once. It would only generate 0,0,0 1,1,1 2,2,2 and so on? Would you not need to cycle the function a few time with offsets on the xyz values individually?

EDIT: unless you put the input values in the xyz arrays multiple times i suppose

This is what I also thought initially, but the loops are attached to each other and the Return node is attached to the first loop so all the loops have to cycle for all values before the first loop is complete. I added a print text node for the vector being made, just before the add to array node and had it print to the log so that I could see all the points after I messed around with values from my construction script in the editor.

Oh yeah, nested loop, I know what that means now.

Nice