I’m trying to make a TArray of a Struct it compiles in visual studio but the editor crushes.
This is my .h file:
uint32 stasts = 0;
class AtptestCharacter : public ACharacter
// here is the auto generated stuff
TArray<FInvItem, TFixedAllocator<7>> Equipment;
I don’t see my mistake and I hope you could help me.
Based on the code provided, IGorilla is correct in that you are trying to access an element of your array that doesn’t exist. After declaring the array, you have to add elements to it (with Equipment.Add([ItemToAdd]) ). Something to note, the “ItemToAdd” has to be of the type that the TArray accepts (in this case ItemToAdd has to be an FInvItem). For example, you could add an FInvItem InventoryWeapon to your .h file, then in the .cpp you would use Equipment.Add(InventoryWeapon). Hope this helps.