Hello,
I have just started learning Unreal and am trying to create a USTRUCT that implements a UINTERFACE
I have an Item struct:
USTRUCT(BlueprintType)
struct FAMINE_API FItem : public IInteractableInterface
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintNativeEvent)
virtual void Interact(class AActor* InteractingActor) override;
private:
UPROPERTY(EditAnywhere, meta = (AllowPrivateAccess = "true"))
class UItemDataAsset* ItemData;
};
and an Interactable UINTERFACE
UINTERFACE(MinimalAPI)
class UInteractableInterface : public UInterface
{
GENERATED_BODY()
};
/**
*
*/
class FAMINE_API IInteractableInterface
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
virtual void Interact(class AActor* InteractingActor) = 0;
};
The problem is that the header tool expects the struct to inherit from another UStruct and then throws the following error at compile time:
Parent Struct âIInteractableInterfaceâ is missing a valid Unreal prefix, expecting âUInteractableInterfaceâ
Is there any way to implement an interface in a UStruct? If not, is my only option then to switch to a UClass?
Thanks!