Making a 2D Array in BluePrints

Hello all,

A friend and I are trying to replicate the Rush Hour board game in Unreal Engine 4 (specifically the 4.9.2).

We’ve currently used an array to create an 8 by 8 square grid in which each square has a name of “TarmacPlane_X” The X would be whatever number the tarmac plane is within the grid and the array. The grid is organised from top-left to top-right like 0 through to 7. When we reach the second row the grid is organised as 8-15. This is fine so far. However when we try to emulate that as an array we do not get a nice easy 0,1,2,3,4,5,6,7,8. Instead we get 0,1,10,11,12,13,14,15, …, 19,2,20,21, etc.

This means our array does not order itself correctly which is frustrating. We need to the array to be organised so that if a car was placed on tarmac plane 45 then to move up we would -8 so the car can land on 37, if the car would move down then we would +8 so that the car moves to square 53 instead. Move either side to side would be easy such as -1 or +1.

Is there a way to organise an array to order itself in a nice easy 0 straight through to 63 (64 squares in an 8 by 8 grid)?

We realise that this is essentially a 2D array but it’s not easy to emulate a 2D array in UE4. A current plan is to have one large array that holds all 8 rows. These 8 rows would then have 8 squares inside of them and the cars would move from array to array in BP if the cars moved up and down (moving side to side would mean that they are still in the same Row Array in the Grid Array).

Would this be the best approach or is there a better approach?

Indeed UE4 does not support array in array even in C++. Maps would be very useful here as it assign index of item to item it self unlike array which index is order in memory but blueprints don’t support them either, they only in C++… if you can use C++ the go for it. Maybe make a structure with object parameter which can be nulled without removing item from array and fill array with those structures and dont delete or add items, just set and null item in struct. The solution you give sounds good too and i think it common way to emulate grid array in community