C++ BlueprintNativeEvent with Interfaces

Hi,

I am trying to create a interface, with a UFunction that is a BlueprintNativeEvent and then to implement that interface in an ActorComponent Class. I watch a lot of tutorials or read similiar Questions here in the forum. I think I set everything up the same way the tutorials did, but I still get the folllowing error:

“UCharacterStatsComponent::SetStatValue_Implementation”: method with override specifier ‘override’ did not override any base class methods

Here is my code:

UINTERFACE(BlueprintType)
class UCharacterStatsInterface : public UInterface
{
	GENERATED_BODY()
};

/**
 * 
 */
class DBRACKETSABILITYSYSTEM_API ICharacterStatsInterface
{
	GENERATED_BODY()

public:
	UFUNCTION()
	virtual FText GetStatValue(FText statName) = 0;

	UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
	void SetStatValue(FText statName, FText value);
};
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class DBRACKETSABILITYSYSTEM_API UCharacterStatsComponent : public UActorComponent, public ICharacterStatsInterface
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UCharacterStatsComponent();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

	virtual FText GetStatValue(FText statName) override;

	void SetStatValue_Implementation(FText statName, FText value) override;
};

I implemented the methods like this in the UCharacterStatsComponent.cpp:

FText UCharacterStatsComponent::GetStatValue(FText statName)
{
	return ICharacterStatsInterface::GetStatValue(statName);
}

void UCharacterStatsComponent::SetStatValue_Implementation(FText statName, FText value)
{
	ICharacterStatsInterface::SetStatValue_Implementation(statName, value);
}

The method GetStatValue, which is not a BlueprintNativeEvent, does not cause an error and works. But the method SetStatValue always causes the error the I mentioned above.

Does someone have an idea what I am doing wrong?

You can’t override a function that’s not virtual, and BlueprintNativeEvent cannot be virtual IIRC;

Anyway, you don’t have to mark it as BlueprintNativeEvent in the interface class. It can be just virtual void SetStatValue(FText statName, FText value) = 0;
And when you override it, you can make it BlueprintNativeEvent.

I might be wrong here, but I think you need to declare a second function in your interface named SetStatValue_Implementation(); and make that one virtual. Then in the class that implements that interface you only override the _implementation version of the method.

Hope this helps