Closed ervacoban closed 4 months ago
What is happening is that when sending the RPC - NotMeRpcTarget.cs code in question:
m_GroupSendTarget.Target.Send(behaviour, ref message, delivery, rpcParams);
if (!behaviour.IsServer)
{
m_ServerRpcTarget.Send(behaviour, ref message, delivery, rpcParams);
}
It will gather the client side of the host and send the RPC but then also send it to the server (which is also the host). Because the host acts as both client and server it will receive two messages.
This could be solved by changing the code to:
m_GroupSendTarget.Target.Send(behaviour, ref message, delivery, rpcParams);
if (!behaviour.IsServer && !m_NetworkManager.ServerIsHost)
{
m_ServerRpcTarget.Send(behaviour, ref message, delivery, rpcParams);
}
Fix is in this PR: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pull/2834 Will land in an upcoming release
Description
When a client, that is not the host, executes an Rpc with target set to NotMe, the host will execute the Rpc twice, locally.
Reproduce Steps
Actual Outcome
When I was executing rpcs with clients, the host executed the rpcs twice, while clients only executed it once. The host should only execute it once as well. This only happens on the host, when a regular client executes the rpc. So this problem does not occur on regular clients.
Expected Outcome
The rpc should only execute once with each call, just like clients.
Screenshots
Host console when rpc was executed from a client: (Bug)
Client console when rpc was executed from the host: (Correct)
Environment
Additional Context
The same problem occured when I was using Unity version 2022.3.10f1 and Netcode 1.8.0 (manual upgrade)