Hi everyone,
I’m working on a multiplayer project using Unity’s Netcode for GameObjects. I have a method marked with [Rpc(SendTo.Everyone)] that is supposed to log messages on both the host and the clients. However, the messages are only being logged on the Host.
[Rpc(SendTo.NotServer)]
private void NotServerRpc(ulong networkObjectId)
{
Debug.Log("SendTo.NotServer Client RPC called");
InvokeClientRpcOnEveryone(networkObjectId);
}
[Rpc(SendTo.Everyone, RequireOwnership = false)]
private void NotifyRpc(ulong networkObjectId)
{
Debug.Log("SendTo.Everyone Client RPC called");
InvokeClientRpcOnEveryone(networkObjectId);
}
private void InvokeClientRpcOnEveryone(ulong networkObjectId)
{
Debug.Log("<color=magenta>Invoking client RPC on everyone. </color> Network object ID: " + networkObjectId);
}
The script is attached to a networked prefab that gets instantiated and spawned in the Start method when the Host is connected. When a new Client connects, it starts a coroutine to check if the object is spawned on the network before calling two different types of ClientRpc methods to print a message. Whenever [Rpc(SendTo.Everyone)] or [Rpc(SendTo.NotServer)] is called, the messages only show on the Host console, not the Client. I am using Parallel Sync to display both the Host and the Client instances.