From ae622bfa576a48952c0fd69defba49ee4b6fb152 Mon Sep 17 00:00:00 2001 From: ninjakickja <80569286+ninjakickja@users.noreply.github.com> Date: Tue, 10 Aug 2021 14:25:37 +0800 Subject: [PATCH] Changes to validation of catchupThreshold - NetworkTransform2k - NetworkTransformBase (#2853) * Changes to validation of catchupThreshold. catchupThreshold needs to be at least 4, or it will interfere/conflict with checking if we have at least 3 old enough buffers. Catchup will decrease buffer while check needs at least 3 older. catchupThreshold should also at least be bufferTimeMultiplier + 2, to take into account of the first 2 snapshots which is used for interpolation, before trying to implement catch up. * Changes to validation of catchupThreshold - NetworkTransform2k - NetworkTransformBase catchupThreshold needs to be at least 4, or it will interfere/conflict with checking if we have at least 3 old enough buffers. Catchup will decrease buffer while check needs at least 3 older. catchupThreshold should also at least be bufferTimeMultiplier + 2, to take into account of the first 2 snapshots which is used for interpolation, before trying to implement catch up. * Changes to validation of catchupThreshold - NetworkTransform2k - NetworkTransformBase catchUpThreshold should be a minimum of bufferTimeMultiplier + 3, to prevent clashes with SnapshotInterpolation looking for at least 3 old enough buffers, else catch up will be implemented while there is not enough old buffers, and will result in jitter. * Update NetworkTransformBase.cs Co-authored-by: vis2k --- .../Components/NetworkTransform2k/NetworkTransformBase.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Assets/Mirror/Components/NetworkTransform2k/NetworkTransformBase.cs b/Assets/Mirror/Components/NetworkTransform2k/NetworkTransformBase.cs index bec58ebed..7d1744abc 100644 --- a/Assets/Mirror/Components/NetworkTransform2k/NetworkTransformBase.cs +++ b/Assets/Mirror/Components/NetworkTransform2k/NetworkTransformBase.cs @@ -453,7 +453,13 @@ protected virtual void OnValidate() // make sure that catchup threshold is > buffer multiplier. // for a buffer multiplier of '3', we usually have at _least_ 3 // buffered snapshots. often 4-5 even. - catchupThreshold = Mathf.Max(bufferTimeMultiplier + 1, catchupThreshold); + // + // catchUpThreshold should be a minimum of bufferTimeMultiplier + 3, + // to prevent clashes with SnapshotInterpolation looking for at least + // 3 old enough buffers, else catch up will be implemented while there + // is not enough old buffers, and will result in jitter. + // (validated with several real world tests by ninja & imer) + catchupThreshold = Mathf.Max(bufferTimeMultiplier + 3, catchupThreshold); // buffer limit should be at least multiplier to have enough in there bufferSizeLimit = Mathf.Max(bufferTimeMultiplier, bufferSizeLimit);