Hey,
I’m trying to get RPC working on a UObject, and I’m aware I require the following:
bool IsSupportedForNetworking() const override;
virtual bool CallRemoteFunction(UFunction* Function, void* Parms, FOutParmRec* OutParms, FFrame* Stack) override;
virtual int32 GetFunctionCallspace(UFunction* Function, void* Parameters, FFrame* Stack) override;
Which is fine and well, however I also appear to require a UPROPERTY
UPROPERTY()
bool bUnused;
If I don’t add this useless property the FFieldCache for my class wont be found, and the CallRemoteFunction will fail to call the remote function.
(screenshot: NetworkDriver.cpp)
Is there a workaround to this? Is there a way to force the creation of a field cache (or subvert the need) for my type without adding a useless property to it?
Thanks.
Also not that I think it’s relevant, but I imagine somebody will want to see it, here’s my implementation of those 3 functions:
bool UInteractionBase::IsSupportedForNetworking() const
{
return true;
}
bool UInteractionBase::CallRemoteFunction(UFunction* Function, void* Parms, FOutParmRec* OutParms, FFrame* Stack)
{
auto* owner = Cast<AActor>(GetOuter());
if (ensure(owner != nullptr))
{
UNetDriver* netDriver = owner->GetNetDriver();
if (ensure(netDriver != nullptr))
{
netDriver->ProcessRemoteFunction(owner, Function, Parms, OutParms, Stack, this);
return true;
}
}
return false;
}
int32 UInteractionBase::GetFunctionCallspace(UFunction* Function, void* Parameters, FFrame* Stack)
{
auto* owner = Cast<AActor>(GetOuter());
check(owner != nullptr);
return (owner ? owner->GetFunctionCallspace(Function, Parameters, Stack) : FunctionCallspace::Local);
}