Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cd11ac6
chore: optimize bitflags in NetworkTransformState
EmandM Oct 31, 2025
c938e7f
Update CHANGELOG
EmandM Oct 31, 2025
a341119
Update IgnoreIfServiceEnvironmentVariableSetAttribute.cs
NoelStephensUnity Oct 31, 2025
85785bc
Apply suggestions from code review
EmandM Nov 3, 2025
cc5d84b
style
NoelStephensUnity Nov 3, 2025
e5c6481
Merge branch 'develop-2.0.0' into chore/optimize-network-transform-state
NoelStephensUnity Nov 3, 2025
8cae595
update
NoelStephensUnity Nov 3, 2025
3ac1439
Fix cumulative state
EmandM Nov 3, 2025
7947790
Merge branch 'develop-2.0.0' into chore/optimize-network-transform-state
EmandM Nov 3, 2025
325dd3d
Merge develop-2.0.0 into chore/optimize-network-transform-state
netcode-ci-service Nov 4, 2025
8e9e353
Merge develop-2.0.0 into chore/optimize-network-transform-state
netcode-ci-service Nov 4, 2025
1ddc91a
Merge develop-2.0.0 into chore/optimize-network-transform-state
netcode-ci-service Nov 4, 2025
e9118f1
Merge develop-2.0.0 into chore/optimize-network-transform-state
netcode-ci-service Nov 14, 2025
10e69a0
Merge develop-2.0.0 into chore/optimize-network-transform-state
netcode-ci-service Nov 14, 2025
e9bb5dc
Merge develop-2.0.0 into chore/optimize-network-transform-state
netcode-ci-service Nov 14, 2025
d56bc4c
Merge develop-2.0.0 into chore/optimize-network-transform-state
netcode-ci-service Nov 17, 2025
a0a9891
Merge develop-2.0.0 into chore/optimize-network-transform-state
netcode-ci-service Nov 18, 2025
077a6ba
Merge develop-2.0.0 into chore/optimize-network-transform-state
netcode-ci-service Nov 19, 2025
25ca971
Fix whitespace issue
EmandM Nov 21, 2025
72ab763
fix
NoelStephensUnity Nov 21, 2025
349f83e
refactor
NoelStephensUnity Nov 21, 2025
d09cb92
update
NoelStephensUnity Nov 21, 2025
d15b193
update
NoelStephensUnity Nov 21, 2025
3f98489
refactor
NoelStephensUnity Nov 22, 2025
09f6bb2
fix
NoelStephensUnity Nov 22, 2025
45c8886
style
NoelStephensUnity Nov 22, 2025
e9787b2
fix
NoelStephensUnity Nov 22, 2025
f7dee36
update
NoelStephensUnity Nov 22, 2025
ffd986f
refactor - EntityId
NoelStephensUnity Nov 22, 2025
e9fd51d
update
NoelStephensUnity Nov 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Changed

- Improve performance of `NetworkTransformState`. (#3770)


### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public struct TransformState

private bool m_OutstandingAuthorityChange = false;

private NetworkManager m_NetworkManager;

#if UNITY_EDITOR
private void Reset()
{
Expand Down Expand Up @@ -159,7 +157,7 @@ public bool ShouldReanticipate
/// <param name="newPosition">The anticipated position</param>
public void AnticipateMove(Vector3 newPosition)
{
if (m_NetworkManager == null || m_NetworkManager.ShutdownInProgress || !m_NetworkManager.IsListening)
if (m_CachedNetworkManager == null || m_CachedNetworkManager.ShutdownInProgress || !m_CachedNetworkManager.IsListening)
{
return;
}
Expand All @@ -172,7 +170,7 @@ public void AnticipateMove(Vector3 newPosition)

m_PreviousAnticipatedTransform = m_AnticipatedTransform;

m_LastAnticipaionCounter = m_NetworkManager.AnticipationSystem.AnticipationCounter;
m_LastAnticipaionCounter = m_CachedNetworkManager.AnticipationSystem.AnticipationCounter;

m_SmoothDuration = 0;
m_CurrentSmoothTime = 0;
Expand All @@ -185,7 +183,7 @@ public void AnticipateMove(Vector3 newPosition)
/// <param name="newRotation">The anticipated rotation</param>
public void AnticipateRotate(Quaternion newRotation)
{
if (m_NetworkManager == null || m_NetworkManager.ShutdownInProgress || !m_NetworkManager.IsListening)
if (m_CachedNetworkManager == null || m_CachedNetworkManager.ShutdownInProgress || !m_CachedNetworkManager.IsListening)
{
return;
}
Expand All @@ -198,7 +196,7 @@ public void AnticipateRotate(Quaternion newRotation)

m_PreviousAnticipatedTransform = m_AnticipatedTransform;

m_LastAnticipaionCounter = m_NetworkManager.AnticipationSystem.AnticipationCounter;
m_LastAnticipaionCounter = m_CachedNetworkManager.AnticipationSystem.AnticipationCounter;

m_SmoothDuration = 0;
m_CurrentSmoothTime = 0;
Expand All @@ -211,7 +209,7 @@ public void AnticipateRotate(Quaternion newRotation)
/// <param name="newScale">The anticipated scale</param>
public void AnticipateScale(Vector3 newScale)
{
if (m_NetworkManager == null || m_NetworkManager.ShutdownInProgress || !m_NetworkManager.IsListening)
if (m_CachedNetworkManager == null || m_CachedNetworkManager.ShutdownInProgress || !m_CachedNetworkManager.IsListening)
{
return;
}
Expand All @@ -224,7 +222,7 @@ public void AnticipateScale(Vector3 newScale)

m_PreviousAnticipatedTransform = m_AnticipatedTransform;

m_LastAnticipaionCounter = m_NetworkManager.AnticipationSystem.AnticipationCounter;
m_LastAnticipaionCounter = m_CachedNetworkManager.AnticipationSystem.AnticipationCounter;

m_SmoothDuration = 0;
m_CurrentSmoothTime = 0;
Expand All @@ -237,7 +235,7 @@ public void AnticipateScale(Vector3 newScale)
/// <param name="newState">The anticipated transform state</param>
public void AnticipateState(TransformState newState)
{
if (m_NetworkManager == null || m_NetworkManager.ShutdownInProgress || !m_NetworkManager.IsListening)
if (m_CachedNetworkManager == null || m_CachedNetworkManager.ShutdownInProgress || !m_CachedNetworkManager.IsListening)
{
return;
}
Expand Down Expand Up @@ -266,7 +264,7 @@ private void ProcessSmoothing()

if (m_CurrentSmoothTime < m_SmoothDuration)
{
m_CurrentSmoothTime += m_NetworkManager.RealTimeProvider.DeltaTime;
m_CurrentSmoothTime += m_CachedNetworkManager.RealTimeProvider.DeltaTime;
var transform_ = transform;
var pct = math.min(m_CurrentSmoothTime / m_SmoothDuration, 1f);

Expand Down Expand Up @@ -399,8 +397,8 @@ protected internal override void InternalOnNetworkSessionSynchronized()
ResetAnticipatedState();

m_AnticipatedObject = new AnticipatedObject { Transform = this };
m_NetworkManager.AnticipationSystem.RegisterForAnticipationEvents(m_AnticipatedObject);
m_NetworkManager.AnticipationSystem.AllAnticipatedObjects.Add(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.RegisterForAnticipationEvents(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.AllAnticipatedObjects.Add(m_AnticipatedObject);
}
}

Expand All @@ -412,23 +410,23 @@ protected internal override void InternalOnNetworkSessionSynchronized()
protected internal override void InternalOnNetworkPostSpawn()
{
base.InternalOnNetworkPostSpawn();
if (!CanCommitToTransform && m_NetworkManager.IsConnectedClient && !SynchronizeState.IsSynchronizing)
if (!CanCommitToTransform && m_CachedNetworkManager.IsConnectedClient && !SynchronizeState.IsSynchronizing)
{
m_OutstandingAuthorityChange = true;
ApplyAuthoritativeState();
ResetAnticipatedState();
m_AnticipatedObject = new AnticipatedObject { Transform = this };
m_NetworkManager.AnticipationSystem.RegisterForAnticipationEvents(m_AnticipatedObject);
m_NetworkManager.AnticipationSystem.AllAnticipatedObjects.Add(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.RegisterForAnticipationEvents(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.AllAnticipatedObjects.Add(m_AnticipatedObject);
}
}

/// <inheritdoc/>
public override void OnNetworkSpawn()
{
m_NetworkManager = NetworkManager;
m_CachedNetworkManager = NetworkManager;

if (m_NetworkManager.DistributedAuthorityMode)
if (m_CachedNetworkManager.DistributedAuthorityMode)
{
Debug.LogWarning($"This component is not currently supported in distributed authority.");
}
Expand All @@ -445,18 +443,18 @@ public override void OnNetworkSpawn()
ResetAnticipatedState();

m_AnticipatedObject = new AnticipatedObject { Transform = this };
m_NetworkManager.AnticipationSystem.RegisterForAnticipationEvents(m_AnticipatedObject);
m_NetworkManager.AnticipationSystem.AllAnticipatedObjects.Add(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.RegisterForAnticipationEvents(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.AllAnticipatedObjects.Add(m_AnticipatedObject);
}

/// <inheritdoc/>
public override void OnNetworkDespawn()
{
if (m_AnticipatedObject != null)
{
m_NetworkManager.AnticipationSystem.DeregisterForAnticipationEvents(m_AnticipatedObject);
m_NetworkManager.AnticipationSystem.AllAnticipatedObjects.Remove(m_AnticipatedObject);
m_NetworkManager.AnticipationSystem.ObjectsToReanticipate.Remove(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.DeregisterForAnticipationEvents(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.AllAnticipatedObjects.Remove(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.ObjectsToReanticipate.Remove(m_AnticipatedObject);
m_AnticipatedObject = null;
}
ResetAnticipatedState();
Expand All @@ -469,9 +467,9 @@ public override void OnDestroy()
{
if (m_AnticipatedObject != null)
{
m_NetworkManager.AnticipationSystem.DeregisterForAnticipationEvents(m_AnticipatedObject);
m_NetworkManager.AnticipationSystem.AllAnticipatedObjects.Remove(m_AnticipatedObject);
m_NetworkManager.AnticipationSystem.ObjectsToReanticipate.Remove(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.DeregisterForAnticipationEvents(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.AllAnticipatedObjects.Remove(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.ObjectsToReanticipate.Remove(m_AnticipatedObject);
m_AnticipatedObject = null;
}

Expand Down Expand Up @@ -518,7 +516,7 @@ public void Smooth(TransformState from, TransformState to, float durationSeconds
protected override void OnBeforeUpdateTransformState()
{
// this is called when new data comes from the server
m_LastAuthorityUpdateCounter = m_NetworkManager.AnticipationSystem.LastAnticipationAck;
m_LastAuthorityUpdateCounter = m_CachedNetworkManager.AnticipationSystem.LastAnticipationAck;
m_OutstandingAuthorityChange = true;
}

Expand Down Expand Up @@ -571,7 +569,7 @@ protected override void OnTransformUpdated()
m_AnticipatedTransform = m_AuthoritativeTransform;

ShouldReanticipate = true;
m_NetworkManager.AnticipationSystem.ObjectsToReanticipate.Add(m_AnticipatedObject);
m_CachedNetworkManager.AnticipationSystem.ObjectsToReanticipate.Add(m_AnticipatedObject);
}
}
}
Loading