Skip to content

Commit 2bfcf52

Browse files
fix
Only apply the InterpolationBufferTickOffset once.
1 parent 3f97156 commit 2bfcf52

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

com.unity.netcode.gameobjects/Runtime/Components/NetworkTransform.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3929,7 +3929,11 @@ private void UpdateInterpolation()
39293929
#else
39303930
var cachedDeltaTime = Time.deltaTime;
39313931
#endif
3932-
var tickLatency = m_CachedNetworkManager.NetworkTimeSystem.TickLatency + InterpolationBufferTickOffset;
3932+
3933+
// Optional user defined tick offset to be used to push the "render time" (the time that will be used to determine if a state update is available)
3934+
// back in order to provide more room for the interpolator to interpolate towards when latency conditions are impacting the frequency that state
3935+
// updates are received.
3936+
var tickLatency = Mathf.Max(1, m_CachedNetworkManager.NetworkTimeSystem.TickLatency + InterpolationBufferTickOffset);
39333937

39343938
// If using an owner authoritative motion model
39353939
if (!IsServerAuthoritative())
@@ -3946,13 +3950,8 @@ private void UpdateInterpolation()
39463950
}
39473951
}
39483952
}
3949-
// Optional user defined tick offset to be used to push the "render time" (the time that will be used to determine if a state update is available)
3950-
// back in order to provide more room for the interpolator to interpolate towards when latency conditions are impacting the frequency that state
3951-
// updates are received.
3952-
tickLatency += InterpolationBufferTickOffset;
39533953

39543954
var tickLatencyAsTime = m_CachedNetworkManager.LocalTime.TimeTicksAgo(tickLatency).Time;
3955-
39563955
// Smooth dampening and extrapolation specific:
39573956
// We clamp between the tick rate frequency and the tick latency x tick rate frequency
39583957
var minDeltaTime = m_CachedNetworkManager.LocalTime.FixedDeltaTime;

0 commit comments

Comments
 (0)