From 79db3d614ae7ce4a1ffae8df86eca74bf12d4707 Mon Sep 17 00:00:00 2001 From: mischa Date: Wed, 16 Oct 2024 13:12:43 +0200 Subject: [PATCH] save baseline --- .../NetworkTransform/NetworkTransformHybrid2022.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Assets/Mirror/Components/NetworkTransform/NetworkTransformHybrid2022.cs b/Assets/Mirror/Components/NetworkTransform/NetworkTransformHybrid2022.cs index 41ba492b2..1f329faba 100644 --- a/Assets/Mirror/Components/NetworkTransform/NetworkTransformHybrid2022.cs +++ b/Assets/Mirror/Components/NetworkTransform/NetworkTransformHybrid2022.cs @@ -69,6 +69,12 @@ public class NetworkTransformHybrid2022 : NetworkBehaviour // deltas are based on the baseline, need to make sure we don't apply on an old one. byte lastServerBaselineSent = 0; + // last deserialized baseline + byte lastDeserializedBaselineTick = 0; + Vector3 lastDeserializedBaselinePosition = Vector3.zero; + Quaternion lastDeserializedBaselineRotation = Quaternion.identity; + Vector3 lastDeserializedBaselineScale = Vector3.one; + // only sync when changed hack ///////////////////////////////////////// #if onlySyncOnChange_BANDWIDTH_SAVING [Header("Sync Only If Changed")] @@ -259,7 +265,13 @@ void RpcServerToClientBaselineSync(byte baselineTick, Vector3? position, Quatern { // IMPORTANT: baselineTick is a remote "frameCount & 0xff". // this can be != compared but not <> compared! - Debug.LogWarning($"TODO process server->client baseline #{baselineTick}"); + Debug.Log($"client received baseline #{baselineTick}"); + + // save the baseline including tick + lastDeserializedBaselineTick = baselineTick; + if (position.HasValue) lastDeserializedBaselinePosition = position.Value; + if (rotation.HasValue) lastDeserializedBaselineRotation = rotation.Value; + if (scale.HasValue) lastDeserializedBaselineScale = scale.Value; } // only unreliable. see comment above of this file.