How to overide BlueprintNativeEvent method from base class?

Hi!

How can I override a method from a base class (in c++) that is declared as a BlueprintNativeEvent?
I tired to add “_Implementation” to the end of the name of my new method override with no success, (exactly the same signature as the base class except the class it belongs to of course).

I guess I’m just using it wrong but couldn’t find any further information about this issue. So how can you create an override for a base class method defined with BlueprintNativeEvent?

Thanks in advance!

1 Like

Hello, undercover

Please make sure that your function was appropriately implemented in the base class:

//.h file
UFUNCTION(BlueprintNativeEvent)
void Foo();
 virtual void Foo_Implementation();
 
//.cpp
 void ACustomActor::Foo_Implementation()
 {
       // needed functionality
 }

Thus, you’ll be able to override it like this:

virtual void Foo_Implementation() override;

Also please don’t forget to define the function in .cpp file of the derived class:

void ADerivedActor::Foo_Implementation()
 {
      // needed functionality
 }

Hope this helped!

Cheers!

2 Likes

Hi!

I’m trying to override FindPlayerStart from the AGameMode.

I get the following error message:
“error C3668: ‘AMyGameMode::FindPlayerStart_Implemention’ : method with override specifier ‘override’ did not override any base class methods”

My (MyGameMode.h) header looks like this:

AActor* FindPlayerStart_Implemention(AController* Player, const FString& IncomingName) override;

My (MyGameMode.cpp) source like this:

AActor* AMyGameMode::FindPlayerStart_Implemention(AController* Player, const FString& IncomingName)
{
	return nullptr;
}

I’m trying to make the transition from 4.7 to 4.8 but can’t get those previous virtual methods to work anymore. Can you see what I’m doing wrong?

Please note that you should name your method FindPlayerStart_Implementation instead of FindPlayerStart_Implementation.
It is most likely that the error occurs because methods’ names don’t match in base and derived classes.

Changing _Implemntion to _Implementation should fix the problem.

That was a stupid mistake. Thanks a lot for pointing it out, now it works like a charm =)

Is this still usable in 4.13? I try and I get the following:

3>C:\_insomnia\Source\Insomnia_v2\Common/Thing/Time/ThingTime.h(47): error C2535: 'void UThingTime::Foo_Implementation(float)': member function already defined or declared
3>  C:\_insomnia\Source\Insomnia_v2\Common/Thing/Time/ThingTime.h(24): note: see declaration of 'UThingTime::Foo_Implementation'

You will get that error if you use GENERATED_UCLASS_BODY() macro instead of new macro GENERATED_BODY().