Creating a Hex Grid with Transforms Stored for later reference

Hi all, I’ve played with unreal for a year or so but I am working on my first big project.
I need to make a Hex Grid that has the locations of each instance saved so I can reference them later.
My thought process was making vector arrays for each of the x and y coordinates then feeding them into a transform array. Then I can loop through the transforms and generate an instance at each location.
Here is what I have built so far, Issue is it only makes a single row of tiles.





I’m sure its something silly I am not understanding. If anyone can point me in the right direction id very much appreciate it!

welcome to the forums, thanks for posting the screens
return nodes are not compulsive. and could lead to early exit if you dont check them.

you have a couple of issues
in " screenshot 7" the 1st foor loop for gridsizeX seems to me that shouldnt even be there.
the return node in that picture also confused me.

the real issue i think is on Screenshot6 where you do a for each loop on an array, and the array is only ONE element, which happens to be a variable and you are actually discarding the value,
what you would like is a simple for loop with indices, and plug the grdsizey in the “last index”
like you did in screenshot 5 with gridsize x.

also suggestion to do -1 to the gridsizes or youll do one row/colum extra since 0>n-1 . the forloop is index inclusive iirc

ok I have cleaned up and updated my code. I think I misunderstood what transforms did as well so I removed them. Progress has been made as I have a row and a Column spawned. I think my math or my loops are messed up somewhere or both.
As you can see below the tiles spawn the first row and column but then stop and the y row is misshapen.

I think its has to do with my Add instance loops but I keep confusing myself.

your code is confusing me. i will try to give you a logic that seems logical to me.

the way you iterate the points at the end doesnt make sense to me, as well as the way in which you create the points.
unless there is a specific reason to have the x and y points separated i think this is better.
you are not setting the X on the points either.
no need to create a vector variable you can right click on the pin on “add” of the vector and select “split struct pin” and set the components directly (dont overuse though) there might also be a “make vector” or simil.

pd if you havent used blueprintue before, you can copy and paste it into the editor.
pd2 in the screenshots you seem to have declared OddVector and evenVector as regular variables, i think they should be “local” ones

I spent some time going through the posts and research. Happy to say finally have my hex grid! Thank you for the assistance Nande!

Found a new node that simplified the vectors and removed the need for more functions. This is the completed blueprint if anyone wants to use it for reference.

1 Like

There is a macro that can help you with this:

1 Like

@solevade well done!
@pezzott1 cool node, i’ve learnt something today :slight_smile: