From 69ed42e02d4b1416d625f57193eb9ffde687df14 Mon Sep 17 00:00:00 2001 From: miwarnec Date: Mon, 4 Nov 2024 11:13:26 +0100 Subject: [PATCH] nthybrid: OnServerToClient checks for host mode first to avoid noise! --- .../NetworkTransformHybrid2022.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Assets/Mirror/Components/NetworkTransform/NetworkTransformHybrid2022.cs b/Assets/Mirror/Components/NetworkTransform/NetworkTransformHybrid2022.cs index 79613d4d3..50a873fb5 100644 --- a/Assets/Mirror/Components/NetworkTransform/NetworkTransformHybrid2022.cs +++ b/Assets/Mirror/Components/NetworkTransform/NetworkTransformHybrid2022.cs @@ -428,6 +428,17 @@ void RpcServerToClientDelta_Rotation(byte baselineTick, Quaternion rotation) // server broadcasts sync message to all clients protected virtual void OnServerToClientDeltaSync(byte baselineTick, Vector3 position, Quaternion rotation)//, Vector3 scale) { + // in host mode, the server sends rpcs to all clients. + // the host client itself will receive them too. + // -> host server is always the source of truth + // -> we can ignore any rpc on the host client + // => otherwise host objects would have ever growing clientBuffers + // (rpc goes to clients. if isServer is true too then we are host) + if (isServer) return; + + // don't apply for local player with authority + if (IsClientWithAuthority) return; + // ensure this delta is for our last known baseline. // we should never apply a delta on top of a wrong baseline. if (baselineTick != lastDeserializedBaselineTick) @@ -444,17 +455,6 @@ protected virtual void OnServerToClientDeltaSync(byte baselineTick, Vector3 posi return; } - // in host mode, the server sends rpcs to all clients. - // the host client itself will receive them too. - // -> host server is always the source of truth - // -> we can ignore any rpc on the host client - // => otherwise host objects would have ever growing clientBuffers - // (rpc goes to clients. if isServer is true too then we are host) - if (isServer) return; - - // don't apply for local player with authority - if (IsClientWithAuthority) return; - // Debug.Log($"[{name}] Client: received delta for baseline #{baselineTick}"); // on the client, we receive rpcs for all entities.