C++ How to instance UObjects from TArray set in Editor

I have a TArray of UObjects, set in the Editor. Each UObject also has a TArray of Uobjects.

I set the variables on the UObjects in the Editor as well as add to the TArray’s.

The blueprint that all this is set on extends from the C++ class extending UObject. There is a pointer to this on a class extending from AAIController.

UPROPERTY(EditAnywhere, Category = "AI")
    UIAUtilitySystem* UtilitySystem;

This is set in the Editor also.

At runtime, the controller is instanced and calls a function on the UObject with the TArray. It goes into the function fine, it is a valid instance, but the TArray is not valid.

How do I instanciate the TArray, full of UObjects that have the settings set in the Editor?

This is the top UObject, Init is run on it so it is intanced. I removed variables and functions that don’t apply to this.

class CATSNIPER_API UIAUtilitySystem :  UObject
    void Init(ACatAIController* controller);
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI")
    TArray<FIAAction> ActionList;

    ACatAIController* MyController;

Here is the UObject in the list:

struct FIAAction

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI")
    FActionTypeEnum ActionType;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AI")
    TArray<FIAAxis> AxisList;

Thank you.

But is a array of structs, not to mention you not using pointers so they don’t really need installation as non-pointer data type alone creates structure in memory (Same as you don’t need to instantiate uint32 or float), just create new item with AddDefaulted

I’m not following. I set the defaults in the Editor. At runtime the TArray crashes.

The controller calls a function on UIAUtilitySystem, execution goes into the function then at:

int num = ActionList.Num();

it crashes. The data is NULL.

Thanks , your answer got me looking in the right direction.

To fix it I added the Instanced class specifier in the controller:

    UPROPERTY(EditAnywhere, Instanced, Category = "AI")
    UIAUtilitySystem* UtilitySystem;

That was all that was necessary.

With FIAAction? Hmm thn try Add() and try adding FIAAction()