I want a server RPC function which:
- Is callable by both C++ and Blueprints
- Is overrideable in Blueprints as well as C++
The basic C++ declared RPC with BlueprintCallable
gets me the C++ / Blueprint visibility, but NOT the BP overrideable aspect, because you're not allowed to use BlueprintNativeEvent on Server functions. I.e.
UFUNCTION(BlueprintCallable, Server, Reliable)
void DoSomethingOnServer();
I also don't want to just create a BP Server event because that's not visible to C++.
So right now I double-dispatch like this:
// .h
...
public:
UFUNCTION(BlueprintCallable, Server, Reliable)
void DoSomethingOnServer();
protected:
UFUNCTION(BlueprintNativeEvent)
void DoSomethingOnServer_ServerFunc(float Force, FVector CentreOffset);
...
// .cpp
void MyClass::DoSomethingOnServer_Implementation()
{
DoSomethingOnServer_ServerFunc();
}
void MyClass::DoSomethingOnServer_ServerFunc()
{
// Either I can implement stuff here, and/or override in BP
// (If I only want BP right now I can use BlueprintImplementableEvent and skip this C++ impl)
}
This gets me what I want because I can call DoSomethingOnServer
from C++ and BP, and whatever code is in DoSomethingOnServer_ServerFunc
, in either C++ or Blueprints, will be executed server side.
Am I insane? Or is there a better way to hit these feature points?