Download

Declare property as TArray of interface pointers.

This is my UINTERFACE declaration.


UINTERFACE(MinimalAPI)
class UForceSource : public UInterface
{
    GENERATED_BODY()
};

class IForceSource
{
    GENERATED_BODY()
public:

    virtual FVector GetForce() const = 0;
};

I am trying to declare an array of pointers to this interface. None of the options worked.


UPROPERTY() TArray<TScriptInterface<IForceSource*>> ForceSources;


 UPROPERTY() TArray<IForceSource*> ForceSources;


 UPROPERTY() TArray<TScriptInterface<IForceSource>*> ForceSources;

Help me please.

Find myself:


UPROPERTY()
    TArray<TScriptInterface<IForceSource>> ForceSources;


void UVehicleMovementComponent::AddForceSource(TScriptInterface<IForceSource> Source)
{
    ForceSources.Add(Source);
}

void UVehicleMovementComponent::RemoveForceSource(TScriptInterface<IForceSource> Source)
{
    ForceSources.Remove(Source);
}