How to resize array within array?

Room Grid is a struct that contains a struct array named XDim, which in turn contains a struct array named YDim, which in turn contains a struct array named ZDim, which holds enums that represent game tiles. My attempt at creating a 3d array.

When the above script executes, only the XDim array gets resized. Why?

Also, what is the best way to create multidimensional arrays? Googling reveals a number of different ways. Is there a generally accepted “best way” to do this via blueprints? Some of the examples I found are over a year old and may be depreciated by new engine features.

I think that the best approach would be by simply creating a new object with 3 arrays as properties.

for the resize part, you should consider the fact that in computer science the usual approach to resize an array is simply eliminate that array, create a new one and copy the older elements in the new one.
I do not know how it is actually implemented in this case but there is a 99% that it is the same here.
I would avoid resize as much as possible

Thanks.

I may just try to do this in C++ instead.

I would say the reason only XDim is resizing is because it is the only one tied to a variable. You are trying to resize the broken sub-arrays without actually setting anything. Break the sub-array out, set it in a variable, resize that variable, and then use the variable in the next step, and at the end plug the sub-array back into the main array so that your top most variable has the latest info.

don’t know the answer, but there seems to be another issue with your code: the second foreachloop happens after the first one completed. meaning it’s only ran once, but you’d need to run it for each of the ydim-arrays. (i.e. remove connection from completed to exec, make connection from resize to exec)

Yup, but unfortunately still doesn’t work.

Easiest solution probably involves creating temp arrays and assigning those in the loops. I’m going to figure out the C++ way to do this instead.

That seems like a very messy way to do it anyway. Cant you just create your custom struct as an array?

is it possible that the inner arrays are just None and you need to create arrays there first?

i don’t even know how to make empty arrays dynamically, seems Make Array takes the type of the array from the items you put in. :confused:

edit: apparently to create arrays, could just make a function with an array as a local variable and return that.

if you care about using a blueprint solution, could also just “flatten” your data into a one-dimensional array.