Hey all, so there’s a network script already in the game scene that calls other client’s ServerRpc marked as required ownership to false, everything works fine on host & client but when I try to run as server & client, the ServerRpc function on the clients simply doesn’t get called on the server, the server can only send ClientRpcs and nothing happens when you call ServerRpc, is that normal? because it breaks the game…
On scene
public class Giver : NetworkBehaviour
{
void GiveClientsSmt()
{
if(IsServer)
{
player.GetSmtServerRpc();
}
}
}
On players
public class Player : NetworkBehaviour
{
[ServerRpc(RequireOwnership = false)]
public void GetSmtServerRpc()
{
//nothing gets called here
Debug.Log("nope");
//clients don't get the message
GetSmtClientRpc();
}
}
Your code doesn‘t show how and when you call the ServerRpc from a client. The Giver script checks for IsServer, so that cannot be the client code making a call. Or maybe that‘s the bug? Because this will work on the host client, since the host is a server.
I just double checked the call by putting a debug inside IsServer and it gets correctly called on server but weirdly enough it doesn’t call the ServerRpc which is right below it
That’s what you have to do though. This isn’t a bug, it’s part of the specification: “A ServerRpc is a remote procedure call (RPC) that can be only invoked by a client and will always be received and executed on the server/host”