Skip to content

Commit 9adf1e5

Browse files
update
Revert moving where IsTeleportingNextFrame and ExplicitSet are reset. Add WasTeleported to NetworkTransformState in order to preserve whether the pushed state was teleported or not.
1 parent 983bd1b commit 9adf1e5

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,16 @@ internal set
321321
}
322322
}
323323

324+
/// <summary>
325+
/// When overriding <see cref="OnAuthorityPushTransformState(ref NetworkTransformState)"/>, if the state that was
326+
/// pushed was a teleport then this will be set to true.
327+
/// </summary>
328+
/// <remarks>
329+
/// Note that <see cref="IsTeleportingNextFrame"/> will be reset in the event you need to do
330+
/// multiple teleports spread out accoss multiple ticks.
331+
/// </remarks>
332+
public bool WasTeleported { get; internal set; }
333+
324334
/// <summary>
325335
/// When set the <see cref="NetworkTransform"/> is uses interpolation.
326336
/// </summary>
@@ -1897,6 +1907,13 @@ private void TryCommitTransform(ref Transform transformToCommit, bool synchroniz
18971907
// Mark the last tick and the old state (for next ticks)
18981908
m_OldState = m_LocalAuthoritativeNetworkState;
18991909

1910+
// Preserve our teleporting flag in order to know if the state pushed was a teleport
1911+
m_LocalAuthoritativeNetworkState.WasTeleported = m_LocalAuthoritativeNetworkState.IsTeleportingNextFrame;
1912+
1913+
// Reset the teleport and explicit state flags after we have sent the state update.
1914+
// These could be set again in the below OnAuthorityPushTransformState virtual method
1915+
m_LocalAuthoritativeNetworkState.IsTeleportingNextFrame = false;
1916+
m_LocalAuthoritativeNetworkState.ExplicitSet = false;
19001917

19011918
try
19021919
{
@@ -1908,12 +1925,6 @@ private void TryCommitTransform(ref Transform transformToCommit, bool synchroniz
19081925
Debug.LogException(ex);
19091926
}
19101927

1911-
1912-
// Reset the teleport and explicit state flags after we have sent the state update.
1913-
// These could be set again in the below OnAuthorityPushTransformState virtual method
1914-
m_LocalAuthoritativeNetworkState.IsTeleportingNextFrame = false;
1915-
m_LocalAuthoritativeNetworkState.ExplicitSet = false;
1916-
19171928
// The below is part of assuring we only send a frame synch, when sending unreliable deltas, if
19181929
// we have already sent at least one unreliable delta state update. At this point in the callstack,
19191930
// a delta state update has just been sent in the above UpdateTransformState() call and as long as

0 commit comments

Comments
 (0)