How to override a Server RPC in both a child C++ class and Blueprint

The following code won’t compile since a BlueprintNativeEvent cannot be mixed with an RPC

// MyCharacter.h
	UFUNCTION(Server, Reliable, BlueprintCallable, BlueprintNativeEvent)
	virtual void Server_OnDeath();

// MyCharacter.cpp
void AMyCharacter::Server_OnDeath_Implementation()
{
    // some code...
}

If I remove BlueprintNativeEvent, it compiles, but there’s no option to override the function in a child Blueprint class.

If I try overriding it in a child c++ class like this:

// MyCharacterChild.h
	virtual void Server_OnDeath() override;

// MyCharacterChild.cpp
void MyCharacterChild::Server_OnDeath()
{
    // some code that DOESN'T call the parent method via Super::
}

It compiles, but the child method is never called. It’s always the parent

Would someone be so kind as to provide a concrete example as to how Remote RPC functions can be overriden in both C++ and Blueprint child classes? Thanks much!

You need two functions; once that is the RPC, that then invokes the BlueprintNativeEvent.

Thanks for your suggestion! Is this the best way to do it?

What you need to override in the child class is the _Implementation method.

1 Like