Do not write old positions back prevent flickering from old to new positions.

This commit is contained in:
2024-10-22 19:45:43 +02:00
parent 887ec37b67
commit 11e10acc00

View File

@@ -483,13 +483,6 @@ namespace Unity.Netcode.Components
m_AnticipatedTransform = from; m_AnticipatedTransform = from;
m_PreviousAnticipatedTransform = m_AnticipatedTransform; m_PreviousAnticipatedTransform = m_AnticipatedTransform;
if (!CanCommitToTransform)
{
transform_.position = from.Position;
transform_.rotation = from.Rotation;
transform_.localScale = from.Scale;
}
m_SmoothFrom = from; m_SmoothFrom = from;
m_SmoothTo = to; m_SmoothTo = to;
m_SmoothDuration = durationSeconds; m_SmoothDuration = durationSeconds;
@@ -521,8 +514,6 @@ namespace Unity.Netcode.Components
// mark this transform for reanticipation // mark this transform for reanticipation
var transform_ = transform; var transform_ = transform;
var previousAnticipatedTransform = m_AnticipatedTransform;
// Update authority state to catch any possible interpolation data // Update authority state to catch any possible interpolation data
m_AuthoritativeTransform.Position = transform_.position; m_AuthoritativeTransform.Position = transform_.position;
m_AuthoritativeTransform.Rotation = transform_.rotation; m_AuthoritativeTransform.Rotation = transform_.rotation;
@@ -531,18 +522,12 @@ namespace Unity.Netcode.Components
if (!m_OutstandingAuthorityChange) if (!m_OutstandingAuthorityChange)
{ {
// Keep the anticipated value unchanged, we have no updates from the server at all. // Keep the anticipated value unchanged, we have no updates from the server at all.
transform_.position = previousAnticipatedTransform.Position;
transform_.localScale = previousAnticipatedTransform.Scale;
transform_.rotation = previousAnticipatedTransform.Rotation;
return; return;
} }
if (StaleDataHandling == StaleDataHandling.Ignore && m_LastAnticipaionCounter > m_LastAuthorityUpdateCounter) if (StaleDataHandling == StaleDataHandling.Ignore && m_LastAnticipaionCounter > m_LastAuthorityUpdateCounter)
{ {
// Keep the anticipated value unchanged because it is more recent than the authoritative one. // Keep the anticipated value unchanged because it is more recent than the authoritative one.
transform_.position = previousAnticipatedTransform.Position;
transform_.localScale = previousAnticipatedTransform.Scale;
transform_.rotation = previousAnticipatedTransform.Rotation;
return; return;
} }