Looking for a guide, for creating a TArray of structs containing a TArray

I have created an empty class using the wizard, and have played around with trying to create this myself.

I have scrolled up and down the TArray Guide and the Structs guide, on wiki, on unreal forums, and I find myself unable to create this scenario.

I found many people posting that this is the solution to making 2D arrays, but no one elaborates on how this solution works.

My core issue is that after I initiate the first array, I can not call the array as it gives me the error that no argument matches the attempted call.

I have tried re naming, re creating, re saving, basically everything I know to do, and I can make an array of arrays in normal C++, but I never in my life have used structs before till unreal, and I can not for the life of me figure out how to iterate over structs while calling the arrays, and iterating over them.

Nothing can be hard coded, and it can not be done in a while loop, I just need to be able to edit these values using another class, and call upon these values using a getter so I can have:

return TArray(2).struct(TArray(2));
return TArray(2).struct(TArray(1));

and get int values.

If someone could point me in the right direction, I don’t mind reading, and watching videos, I am just having a hard time finding a starting point that makes any sense at all.

Even some example code of something completely irrelevant, but using a struct that is being iterated across with an array of arrays.


USTRUCT()
struct FInnerArray
{
   GENERATED_BODY()

   UPROPERTY()
   TArray<int> InnerArray;
}

UPROPERTY()
TArray<FInnerArray> OuterArray;

You should be able to access your data by using


int Num = OuterArray[0].InnerArray[0];

Hope that helps.
ndelchen

When I copy this, I get the error “identifier “USTRUCT” is undefined.
Followed by a red line under “struct” in struct FinneryArray stating " expected a ;”

I hate posting here because I feel like I am doing something wrong, but I can’t really find a guide anywhere that doesn’t just “talk” about structs and how awesome they are, I understand how awesome, I just don’t fully understand how to implement them.

Need a semi-colon after the closing } of the struct.

When I add a semi colon, UPROPERTY becomes undefined, and TArray underneath it expects ;

basically adding a semi colon after the closing } of the struct makes everything worse.

Let me add in, I do not need UPROPPERTY or UStructs, because this is class object off on it’s own.

Basically, I have a 2d map of integers

(0,1,2,4,2,0)
(1,2,4,0,1,2)
(3,4,2,0,3,1)

etc

That eventually, after I make it work, will be randomly generated by another class, at the start of each game.

All I need right now is a way to store these intigers with x,y components so I can type something like
int Num = OuterArray[0].InnerArray[0]; and get the num i need to generate the correct level the player is walking to.

I am currently HARD coding the numbers in just to make sure the game loads properly from level to level.

I am also now realizing I may be able to use e^matrix to get a value that represents a 2d coordinate, but I am hoping their is an easier way :smiley:

oops! thx for correcting me!

Hmm, your post confuses me… Can you explain again what you want to achieve maybe?