From 6581300ce0254f3f05b602b703d39dff5fa71a8e Mon Sep 17 00:00:00 2001 From: vis2k Date: Sat, 31 Dec 2022 14:34:28 +0100 Subject: [PATCH 1/2] remove unused imports --- .../Components/NetworkTransformUnreliable/NetworkTransform.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs b/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs index 959806eff..ba8724fe3 100644 --- a/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs +++ b/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs @@ -1,8 +1,6 @@ // NetworkTransform V2 by mischa (2021-07) // comment out the below line to quickly revert the onlySyncOnChange feature #define onlySyncOnChange_BANDWIDTH_SAVING -using System; -using System.Collections.Generic; using UnityEngine; namespace Mirror From ca9f07d8120c9affaddb008b7dcc40e121e4a5be Mon Sep 17 00:00:00 2001 From: vis2k Date: Sat, 31 Dec 2022 14:36:57 +0100 Subject: [PATCH 2/2] fix: #3329 NetworkTransform UpdateServer checks if .connectionToClient is null to support room demo / scene changes --- .../NetworkTransformReliable/NetworkTransformReliable.cs | 8 ++++++-- .../NetworkTransformUnreliable/NetworkTransform.cs | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Assets/Mirror/Components/NetworkTransformReliable/NetworkTransformReliable.cs b/Assets/Mirror/Components/NetworkTransformReliable/NetworkTransformReliable.cs index 723d1c8f6..0e983db4a 100644 --- a/Assets/Mirror/Components/NetworkTransformReliable/NetworkTransformReliable.cs +++ b/Assets/Mirror/Components/NetworkTransformReliable/NetworkTransformReliable.cs @@ -133,7 +133,7 @@ protected virtual void OnClientToServerSync(Vector3? position, Quaternion? rotat target.localScale); // Debug.Log($"{name}: corrected history on server to fix initial stutter after not sending for a while."); } - + AddSnapshot(serverSnapshots, connectionToClient.remoteTimeStamp, position, rotation, scale); } @@ -310,7 +310,11 @@ void UpdateServer() // -> don't apply for host mode player objects either, even if in // client authority mode. if it doesn't go over the network, // then we don't need to do anything. - if (syncDirection == SyncDirection.ClientToServer && !isOwned) + // -> connectionToClient is briefly null after scene changes: + // https://github.com/MirrorNetworking/Mirror/issues/3329 + if (syncDirection == SyncDirection.ClientToServer && + connectionToClient != null && + !isOwned) { if (serverSnapshots.Count > 0) { diff --git a/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs b/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs index ba8724fe3..2a59dcb74 100644 --- a/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs +++ b/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs @@ -232,7 +232,11 @@ void UpdateServer() // -> don't apply for host mode player objects either, even if in // client authority mode. if it doesn't go over the network, // then we don't need to do anything. - if (syncDirection == SyncDirection.ClientToServer && !isOwned) + // -> connectionToClient is briefly null after scene changes: + // https://github.com/MirrorNetworking/Mirror/issues/3329 + if (syncDirection == SyncDirection.ClientToServer && + connectionToClient != null && + !isOwned) { if (serverSnapshots.Count > 0) {