Skip to content

Commit c803c72

Browse files
fix: NetworkTransform authority warning [MTT-1291] (#1846)
* fix enabling the NetworkTransform debug information. * test This verifies the authority warning is working on the client side. * style MTT-1291 Added some additional comments and making sure this branch is tracked in the task. * update Added Unity.Netcode.Components to test project's runtime assembly so we can write tests for the components in this test assembly. * style white space removal * update only need to check for isRotationDirty as this is only set when any of the SyncRotAngle[xyz] are set to true. * style * update Fixes the issue where there was no minimum threshold value which meant a user could set the threshold to zero which would cause non-authoritative false-positive warnings. Fixes the issue where NetworkRigidBody was only setting IsKinematic to true when the NetworkObject was spawned which could cause non-authoritative false-positive warnings. Fixes the issue where the very next frame update after OnNetworkSpawn could cause non-authoritative false-positive warnings. Fixes the issue where changing the parent could cause non-authoritative false-positive warnings. Fixes the issue where rotation was improperly checking for a delta rotation that was larger than the rotation threshold. * style removing commented out code * style updating an removing some comments. * update Fixing some issues Fatih caught. Refactoring when we have to delay for the authority check. It is only needed when the parent changes. Removing data size spam messages when LogLevel.Developer. Adding scale and rotation to the test as well as verification that there is no notification when below the threshold. * style * update Adding warning message when any threshold is below the minimum threshold value during OnValidate. * Update CHANGELOG.md * Update CHANGELOG.md * fix fixing some merge issues. * update removing authority warning related code. * update removing components reference since it is no longer needed. * update * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md
1 parent 4008889 commit c803c72

File tree

2 files changed

+0
-42
lines changed

2 files changed

+0
-42
lines changed

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

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
284284

285285
private NetworkTransformState m_LocalAuthoritativeNetworkState;
286286

287-
private NetworkTransformState m_PrevNetworkState;
288-
289287
private const int k_DebugDrawLineTime = 10;
290288

291289
private bool m_HasSentLastValue = false; // used to send one last value, so clients can make the difference between lost replication data (clients extrapolate) and no more data to send.
@@ -523,8 +521,6 @@ internal bool ApplyTransformToNetworkState(ref NetworkTransformState networkStat
523521

524522
private void ApplyInterpolatedNetworkStateToTransform(NetworkTransformState networkState, Transform transformToUpdate)
525523
{
526-
m_PrevNetworkState = networkState;
527-
528524
var interpolatedPosition = InLocalSpace ? transformToUpdate.localPosition : transformToUpdate.position;
529525

530526
// todo: we should store network state w/ quats vs. euler angles
@@ -601,8 +597,6 @@ private void ApplyInterpolatedNetworkStateToTransform(NetworkTransformState netw
601597
{
602598
transformToUpdate.position = interpolatedPosition;
603599
}
604-
605-
m_PrevNetworkState.Position = interpolatedPosition;
606600
}
607601

608602
// RotAngles Apply
@@ -616,15 +610,12 @@ private void ApplyInterpolatedNetworkStateToTransform(NetworkTransformState netw
616610
{
617611
transformToUpdate.rotation = Quaternion.Euler(interpolatedRotAngles);
618612
}
619-
620-
m_PrevNetworkState.Rotation = interpolatedRotAngles;
621613
}
622614

623615
// Scale Apply
624616
if (SyncScaleX || SyncScaleY || SyncScaleZ)
625617
{
626618
transformToUpdate.localScale = interpolatedScale;
627-
m_PrevNetworkState.Scale = interpolatedScale;
628619
}
629620
}
630621

@@ -893,8 +884,6 @@ protected virtual void Update()
893884
{
894885
TryCommitTransformToServer(m_Transform, m_CachedNetworkManager.LocalTime.Time);
895886
}
896-
897-
m_PrevNetworkState = m_LocalAuthoritativeNetworkState;
898887
}
899888

900889
// apply interpolated value
@@ -918,36 +907,10 @@ protected virtual void Update()
918907

919908
if (!CanCommitToTransform)
920909
{
921-
#if NGO_TRANSFORM_DEBUG
922-
if (m_CachedNetworkManager.LogLevel == LogLevel.Developer)
923-
{
924-
// TODO: This should be a component gizmo - not some debug draw based on log level
925-
var interpolatedPosition = new Vector3(m_PositionXInterpolator.GetInterpolatedValue(), m_PositionYInterpolator.GetInterpolatedValue(), m_PositionZInterpolator.GetInterpolatedValue());
926-
Debug.DrawLine(interpolatedPosition, interpolatedPosition + Vector3.up, Color.magenta, k_DebugDrawLineTime, false);
927-
928-
// try to update previously consumed NetworkState
929-
// if we have any changes, that means made some updates locally
930-
// we apply the latest ReplNetworkState again to revert our changes
931-
var oldStateDirtyInfo = ApplyTransformToNetworkStateWithInfo(ref m_PrevNetworkState, 0, m_Transform);
932-
933-
// there are several bugs in this code, as we the message is dumped out under odd circumstances
934-
// For Matt, it would trigger when an object's rotation was perturbed by colliding with another
935-
// object vs. explicitly rotating it
936-
if (oldStateDirtyInfo.isPositionDirty || oldStateDirtyInfo.isScaleDirty || (oldStateDirtyInfo.isRotationDirty && SyncRotAngleX && SyncRotAngleY && SyncRotAngleZ))
937-
{
938-
// ignoring rotation dirty since quaternions will mess with euler angles, making this impossible to determine if the change to a single axis comes
939-
// from an unauthorized transform change or euler to quaternion conversion artifacts.
940-
var dirtyField = oldStateDirtyInfo.isPositionDirty ? "position" : oldStateDirtyInfo.isRotationDirty ? "rotation" : "scale";
941-
Debug.LogWarning($"A local change to {dirtyField} without authority detected, reverting back to latest interpolated network state!", this);
942-
}
943-
}
944-
#endif
945-
946910
// Apply updated interpolated value
947911
ApplyInterpolatedNetworkStateToTransform(m_ReplicatedNetworkState.Value, m_Transform);
948912
}
949913
}
950-
951914
m_LocalAuthoritativeNetworkState.IsTeleportingNextFrame = false;
952915
}
953916

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,11 +1417,6 @@ private void HandleRawTransportPoll(NetworkEvent networkEvent, ulong clientId, A
14171417
break;
14181418
case NetworkEvent.Data:
14191419
{
1420-
if (NetworkLog.CurrentLogLevel <= LogLevel.Developer)
1421-
{
1422-
NetworkLog.LogInfo($"Incoming Data From {clientId}: {payload.Count} bytes");
1423-
}
1424-
14251420
clientId = TransportIdToClientId(clientId);
14261421

14271422
HandleIncomingData(clientId, payload, receiveTime);

0 commit comments

Comments
 (0)