Skip to content

Commit 748d01e

Browse files
update
MTT-4521 Renamed StopExtrapolatingLastState to TryToStopExtrapolatingLastState. Added/adjusted comments.
1 parent d39b0d7 commit 748d01e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ private void AddInterpolatedState(NetworkTransformState newState)
974974
/// <remarks>
975975
/// <see cref="OnNetworkStateChanged"/>
976976
/// </remarks>
977-
private void StopExtrapolatingLastState()
977+
private void TryToStopExtrapolatingLastState()
978978
{
979979
if (!m_LastReceivedState.IsDirty || m_LastReceivedState.EndExtrapolationTick >= NetworkManager.LocalTime.Tick)
980980
{
@@ -1006,9 +1006,15 @@ private void OnNetworkStateChanged(NetworkTransformState oldState, NetworkTransf
10061006
{
10071007
// This is "just in case" we receive a new state before the end
10081008
// of any currently applied and potentially extrapolating state.
1009-
StopExtrapolatingLastState();
1009+
// Attempts to stop extrapolating any previously applied state.
1010+
TryToStopExtrapolatingLastState();
1011+
1012+
// Add measurements for the new state's deltas
10101013
AddInterpolatedState(newState);
1014+
1015+
// Set the last received state to the new state (will be used to stop extrapolating the new state on the next local tick)
10111016
m_LastReceivedState = newState;
1017+
10121018
// Set the current local tick and wait until the next tick before we end
10131019
// this state's extrapolation.
10141020
m_LastReceivedState.EndExtrapolationTick = NetworkManager.LocalTime.Tick;
@@ -1312,9 +1318,8 @@ protected virtual void Update()
13121318
// Apply the current authoritative state
13131319
ApplyAuthoritativeState();
13141320

1315-
// Handles stopping extrapolation for any previously
1316-
// applied state.
1317-
StopExtrapolatingLastState();
1321+
// Attempts to stop extrapolating any previously applied state.
1322+
TryToStopExtrapolatingLastState();
13181323
}
13191324
}
13201325

0 commit comments

Comments
 (0)