I’m attempting to get a simple interface added in UE4 in C++. Unfortunately, I’ve been unable to get the interface to work correctly. I’m getting a couple of errors:
error C3668: ‘APhoenixCharacter::GetEnergy’ : method with override specifier ‘override’ did not override any base class methods
and
error C2512: ‘IPhoenixInterface’ : no appropriate default constructor available.
Any help would be much appreciated.
Interface.h
UINTERFACE(Blueprintable, Category = "Phoenix Interface")
class PHOENIX_API UPhoenixInterface : public UInterface
{
GENERATED_UINTERFACE_BODY()
public:
};
class IPhoenixInterface
{
GENERATED_IINTERFACE_BODY()
public:
IPhoenixInterface(const FObjectInitializer & PCIP);
//UFUNCTION(BlueprintImplementableEvent)
float GetEnergy();
};
Interface.cpp
UPhoenixInterface::UPhoenixInterface(const FObjectInitializer & PCIP)
: Super(PCIP)
{
}
IPhoenixInterface::IPhoenixInterface(const FObjectInitializer & PCIP = FObjectInitializer::Get())
{
}
float IPhoenixInterface::GetEnergy()
{
return 1.0f;
}
character.h
UCLASS()
class PHOENIX_API APhoenixCharacter : public ACharacter, public IPhoenixInterface
{
GENERATED_BODY()
//Interface Overrides
public:
//UFUNCTION(BlueprintImplementableEvent)
float GetEnergy() override;