diff --git a/Assets/Mirror/Components/NetworkTransformBase.cs b/Assets/Mirror/Components/NetworkTransformBase.cs index 0781932c4..bda8d8152 100644 --- a/Assets/Mirror/Components/NetworkTransformBase.cs +++ b/Assets/Mirror/Components/NetworkTransformBase.cs @@ -57,6 +57,31 @@ public abstract class NetworkTransformBase : NetworkBehaviour [Tooltip("Set to false to remove scale smoothing. Example use-case: Instant flipping of sprites that use -X and +X for direction.")] public bool interpolateScale = true; + [Header("Send Interval Multiplier")] + [Tooltip("Check/Sync every multiple of Network Manager send interval (= 1 / NM Send Rate), instead of every send interval.")] + [Range(1, 120)] + public uint sendIntervalMultiplier = 1; // not implemented yet + + [Header("Timeline Offset")] + [Tooltip("Add a small timeline offset to account for decoupled arrival of NetworkTime and NetworkTransform snapshots.\nfixes: https://github.com/MirrorNetworking/Mirror/issues/3427")] + public bool timelineOffset = false; + + // Ninja's Notes on offset & mulitplier: + // + // In a no multiplier scenario: + // 1. Snapshots are sent every frame (frame being 1 NM send interval). + // 2. Time Interpolation is set to be 'behind' by 2 frames times. + // In theory where everything works, we probably have around 2 snapshots before we need to interpolate snapshots. From NT perspective, we should always have around 2 snapshots ready, so no stutter. + // + // In a multiplier scenario: + // 1. Snapshots are sent every 10 frames. + // 2. Time Interpolation remains 'behind by 2 frames'. + // When everything works, we are receiving NT snapshots every 10 frames, but start interpolating after 2. + // Even if I assume we had 2 snapshots to begin with to start interpolating (which we don't), by the time we reach 13th frame, we are out of snapshots, and have to wait 7 frames for next snapshot to come. This is the reason why we absolutely need the timestamp adjustment. We are starting way too early to interpolate. + // + protected double timeStampAdjustment => NetworkServer.sendInterval * (sendIntervalMultiplier - 1); + protected double offset => timelineOffset ? NetworkServer.sendInterval * sendIntervalMultiplier : 0; + // debugging /////////////////////////////////////////////////////////// [Header("Debug")] public bool showGizmos; diff --git a/Assets/Mirror/Components/NetworkTransformReliable/NetworkTransformReliable.cs b/Assets/Mirror/Components/NetworkTransformReliable/NetworkTransformReliable.cs index 1814278e3..855652581 100644 --- a/Assets/Mirror/Components/NetworkTransformReliable/NetworkTransformReliable.cs +++ b/Assets/Mirror/Components/NetworkTransformReliable/NetworkTransformReliable.cs @@ -18,11 +18,6 @@ public class NetworkTransformReliable : NetworkTransformBase [Tooltip("If we only sync on change, then we need to correct old snapshots if more time than sendInterval * multiplier has elapsed.\n\nOtherwise the first move will always start interpolating from the last move sequence's time, which will make it stutter when starting every time.")] public float onlySyncOnChangeCorrectionMultiplier = 2; - [Header("Send Interval Multiplier")] - [Tooltip("Check/Sync every multiple of Network Manager send interval (= 1 / NM Send Rate), instead of every send interval.")] - [Range(1, 120)] - public uint sendIntervalMultiplier = 3; - [Header("Rotation")] [Tooltip("Sensitivity of changes needed before an updated state is sent over the network")] public float rotationSensitivity = 0.01f; @@ -42,26 +37,6 @@ public class NetworkTransformReliable : NetworkTransformBase [Range(0.00_01f, 1f)] // disallow 0 division. 1mm to 1m precision is enough range. public float scalePrecision = 0.01f; // 1 cm - [Header("Snapshot Interpolation")] - [Tooltip("Add a small timeline offset to account for decoupled arrival of NetworkTime and NetworkTransform snapshots.\nfixes: https://github.com/MirrorNetworking/Mirror/issues/3427")] - public bool timelineOffset = false; - - // Ninja's Notes on offset & mulitplier: - // - // In a no multiplier scenario: - // 1. Snapshots are sent every frame (frame being 1 NM send interval). - // 2. Time Interpolation is set to be 'behind' by 2 frames times. - // In theory where everything works, we probably have around 2 snapshots before we need to interpolate snapshots. From NT perspective, we should always have around 2 snapshots ready, so no stutter. - // - // In a multiplier scenario: - // 1. Snapshots are sent every 10 frames. - // 2. Time Interpolation remains 'behind by 2 frames'. - // When everything works, we are receiving NT snapshots every 10 frames, but start interpolating after 2. - // Even if I assume we had 2 snapshots to begin with to start interpolating (which we don't), by the time we reach 13th frame, we are out of snapshots, and have to wait 7 frames for next snapshot to come. This is the reason why we absolutely need the timestamp adjustment. We are starting way too early to interpolate. - // - double timeStampAdjustment => NetworkServer.sendInterval * (sendIntervalMultiplier - 1); - double offset => timelineOffset ? NetworkServer.sendInterval * sendIntervalMultiplier : 0; - // delta compression needs to remember 'last' to compress against protected Vector3Long lastSerializedPosition = Vector3Long.zero; protected Vector3Long lastDeserializedPosition = Vector3Long.zero; diff --git a/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs b/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs index 85ca52dd5..51a46ca09 100644 --- a/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs +++ b/Assets/Mirror/Components/NetworkTransformUnreliable/NetworkTransform.cs @@ -36,31 +36,6 @@ public class NetworkTransform : NetworkTransformBase protected bool hasSentUnchangedPosition; #endif - [Header("Send Interval Multiplier")] - [Tooltip("Check/Sync every multiple of Network Manager send interval (= 1 / NM Send Rate), instead of every send interval.")] - [Range(1, 120)] - const uint sendIntervalMultiplier = 1; // not implemented yet - - [Header("Snapshot Interpolation")] - [Tooltip("Add a small timeline offset to account for decoupled arrival of NetworkTime and NetworkTransform snapshots.\nfixes: https://github.com/MirrorNetworking/Mirror/issues/3427")] - public bool timelineOffset = false; - - // Ninja's Notes on offset & mulitplier: - // - // In a no multiplier scenario: - // 1. Snapshots are sent every frame (frame being 1 NM send interval). - // 2. Time Interpolation is set to be 'behind' by 2 frames times. - // In theory where everything works, we probably have around 2 snapshots before we need to interpolate snapshots. From NT perspective, we should always have around 2 snapshots ready, so no stutter. - // - // In a multiplier scenario: - // 1. Snapshots are sent every 10 frames. - // 2. Time Interpolation remains 'behind by 2 frames'. - // When everything works, we are receiving NT snapshots every 10 frames, but start interpolating after 2. - // Even if I assume we had 2 snapshots to begin with to start interpolating (which we don't), by the time we reach 13th frame, we are out of snapshots, and have to wait 7 frames for next snapshot to come. This is the reason why we absolutely need the timestamp adjustment. We are starting way too early to interpolate. - // - double timeStampAdjustment => NetworkServer.sendInterval * (sendIntervalMultiplier - 1); - double offset => timelineOffset ? NetworkServer.sendInterval * sendIntervalMultiplier : 0; - // update ////////////////////////////////////////////////////////////// // Update applies interpolation void Update()