Hey guys,
So I’m calling the following function in my custom player controller’s Tick function;
UFUNCTION(Client, Unreliable, Category = Time)
void ReceiveServerTime_Client(float RawServerTime);
Inside Tick:
// On any kind of server
if ((GetNetMode() == NM_DedicatedServer) || (GetNetMode() == NM_ListenServer) || GetNetMode() == NM_Standalone)
{
ServerTime = World->RealTimeSeconds;
if (!IsLocalController()) // works as intended - only returns false on server
{
if (World->RealTimeSeconds > NextTimeSend)
{
//GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, FString::SanitizeFloat(ServerTime));
UE_LOG(LogTemp, Warning, TEXT("Time on Server = %f"), World->RealTimeSeconds);
ReceiveServerTime_Client_Implementation(World->RealTimeSeconds); // call RPC server->client so client can receive this value
NextTimeSend = World->RealTimeSeconds + TimeUpdateDelay;
}
}
}
Inside that function, IsLocalController() returns false, and HasAuthority() returns true. I stepped into them and realized something - inside an RPC running on the client and called from a dedicated server, the net mode is NM_DedicatedServer, and the role is ROLE_Authority, despite this not being the case inside the normal Tick function when running on the client (this proves that the controller can tell if it’s local or not under normal circumstances, but not inside an RPC running on the client).
Can anyone shed light on this?
Thanks.