virtual Interface function

UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = “IDamageable”)
virtual ETeam GetTeam();

Error: …/DamageableInterface.h(21) : BlueprintImplementableEvents in Interfaces must not be declared ‘virtual’

It’s NOT a BlueprintImplementableEvent… It’s a BlueprintNativeEvent, I assume that this is a minor UE4-bug. But sadly according to the internal code even if it would work correctly, it would still throw an error for BlueprintNativeEvents:

So basically, virtual methods are no longer allowed for blueprint interfaces but they are allowed for C++ ones?

I also found this: Are there plans to add the ability to override virtual functions in Blueprint? - Blueprint Visual Scripting - Unreal Engine Forums where it is said that by default “all interface functions are virtual by default”. This however is not true because when I put this in my character-class (header):

ETeam GetTeam() override;

It will tell me that it can not find a function to override… If I remove the override it will work. I’m a bit confused…

That is because that function will be generated by UHT and will contain code calling blueprint event, otherwise calling this function in C++ would not call out event in blueprint, this is scar that BlueprintNativeEvent do. No worries all you need to do is create function with _Implementation surfix, like this:

virtual ETeam GetTeam_Implementation();

It will be called when event is triggered

2 Likes