Posted originally here: unreal - Interface in UE5 not casting or working as a variable - Game Development Stack Exchange
In UE5.3.2, I have created an interface in C++ (code at the end) that I’m trying to implement in a Blueprint. The editor gets the type correctly, and I have been able to make a simple implementation:
The implementation is a blueprint
Object
named GoldCpp
. However, I can’t use this type or I can’t cast it:
The cast always fails (and prints false), and the “default value” for the
ItemInterface
shows no options. What am I missing?
// This class does not need to be modified.
UINTERFACE(MinimalAPI, Blueprintable)
class UItemInterface : public UInterface
{
GENERATED_BODY()
};
/**
*
*/
class LASTWORLD_API IItemInterface
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
UStaticMesh * GetMesh();
};