I was wondering if it’s possible to make an array with both rows and columns. Now i imagine arrays as a single row of entries, whereas i can imagine a lot of uses for an array with row and column entries.
Let’s for simplicity say i want to create a 3x3 tiled map of some sort, and the middle room contains an up/down hall. Then i could loop thorugh the array, and it would find the room at (x,y)=(2,2) and place connecting walls at (x,y-1) = (2,1) and (x,y+1) = (2,3). Or how do people go about that kind of business?
It’s called a 2D array, or 3D if you are going another step on each element too. In blueprints alone with an array UE4 doesn’t support those. You will want to create a struct with array objects for it’s fields to achieve this. I populate mine through dataset’s and then you can load them in as regular array variables and add or remove as necessary during runtime (To the local array variable, not the dataset)
Jamendxman3: It was also something like that i had in mind, when converting from 1D to 2D, however a bit cumbersome to do if you change the grid, and want to look the entry above and below, up.
ZoltanJr and: A struct seems like the best alternative to do this with, where you effectively can make a (x,y) structure
and when you want to retrieve items, you do the same thing.
To flip the grid to go from right to left or vice versa, you just swap the x and the y in the equation. Those are the only variables you’d need to change.