Creating Structs and adding them to TArrays.

I have a struct called FStruct and TArray of FStruct called ArrayOfStructs both declared in my header file. In my .cpp I want to create a new FStruct, assign certain variables to certain values, and put the FStruct into my ArrayOfStructs at index i. The only way I have found to create an FStruct that Allows me to assign the variables of that struct to certain values is as follows:

FStruct NewStruct; NewStruct.SomeActorPtr = SomeActorPtr; NewStruct.SomeActorPtrsRotation = NewStruct.SomeActorPtr->GetActorRotation();

If I use that code to add multiple structs to the array how will the structs be differentiated since they are all called “NewStruct”, or will they all be considered the same struct? If they are all the same how could I make different structs of the type “FStruct”?

Once you add your structs into a TArray, they will be inside your array in memory, it doesn’t matter if you use the same pointer/variable when you create the struct (e.g. you are using a cycle to create a struct, fill it with data, and adding it to the array).

You will be able to retrieve your structs using the TArray.

I suggest you to read the documentation of TArrays which contains a lot about how to sort or iterate over the array.

If you need further assistance, comment below and I will be glad to help.