Skip to content

Commit f0fb0fd

Browse files
update
Updating PositionMaxInterpolationTime, RotationMaxInterpolationTime, and ScaleMaxInterpolationTime to be set when `NetworkTransform.SetMaxInterpolationBound` is invoked.
1 parent 65dac85 commit f0fb0fd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3149,6 +3149,9 @@ private void OnNetworkStateChanged(NetworkTransformState oldState, NetworkTransf
31493149
/// <param name="maxInterpolationBound">Maximum time boundary that can be used in a frame when interpolating between two values</param>
31503150
public void SetMaxInterpolationBound(float maxInterpolationBound)
31513151
{
3152+
PositionMaxInterpolationTime = maxInterpolationBound;
3153+
RotationMaxInterpolationTime = maxInterpolationBound;
3154+
ScaleMaxInterpolationTime = maxInterpolationBound;
31523155
m_RotationInterpolator.MaxInterpolationBound = maxInterpolationBound;
31533156
m_PositionInterpolator.MaxInterpolationBound = maxInterpolationBound;
31543157
m_ScaleInterpolator.MaxInterpolationBound = maxInterpolationBound;
@@ -3937,10 +3940,14 @@ private void UpdateInterpolation()
39373940
}
39383941
}
39393942
}
3943+
// 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)
3944+
// back in order to provide more room for the interpolator to interpolate towards when latency conditions are impacting the frequency that state
3945+
// updates are received.
39403946
tickLatency += InterpolationBufferTickOffset;
3947+
39413948
var tickLatencyAsTime = m_CachedNetworkManager.LocalTime.TimeTicksAgo(tickLatency).Time;
39423949

3943-
// Smooth dampening specific:
3950+
// Smooth dampening and extrapolation specific:
39443951
// We clamp between the tick rate frequency and the tick latency x tick rate frequency
39453952
var minDeltaTime = m_CachedNetworkManager.LocalTime.FixedDeltaTime;
39463953

@@ -3957,6 +3964,7 @@ private void UpdateInterpolation()
39573964
m_PositionInterpolator.MaximumInterpolationTime = PositionMaxInterpolationTime;
39583965
}
39593966

3967+
// If either of these two position interpolation related values have changed, then reset the current state being interpolated.
39603968
if (m_PreviousPositionInterpolationType != PositionInterpolationType || m_PreviousPositionLerpSmoothing != PositionLerpSmoothing)
39613969
{
39623970
m_PreviousPositionInterpolationType = PositionInterpolationType;
@@ -3982,6 +3990,7 @@ private void UpdateInterpolation()
39823990
m_RotationInterpolator.MaximumInterpolationTime = RotationMaxInterpolationTime;
39833991
}
39843992

3993+
// If either of these two rotation interpolation related values have changed, then reset the current state being interpolated.
39853994
if (m_PreviousRotationInterpolationType != RotationInterpolationType || m_PreviousRotationLerpSmoothing != RotationLerpSmoothing)
39863995
{
39873996
m_PreviousRotationInterpolationType = RotationInterpolationType;
@@ -4011,6 +4020,7 @@ private void UpdateInterpolation()
40114020
m_ScaleInterpolator.MaximumInterpolationTime = ScaleMaxInterpolationTime;
40124021
}
40134022

4023+
// If either of these two rotation interpolation related values have changed, then reset the current state being interpolated.
40144024
if (m_PreviousScaleInterpolationType != ScaleInterpolationType || m_PreviousScaleLerpSmoothing != ScaleLerpSmoothing)
40154025
{
40164026
m_PreviousScaleInterpolationType = ScaleInterpolationType;

0 commit comments

Comments
 (0)