Skip to content

Commit 511af60

Browse files
fix
Only the spawn authority should reset the sent time and reset the dirty flag for NetworkList changes to avoid sending both the CreateObjectMessage (which would contain the changes) plus the NetworkVariableDeltaMessage.
1 parent 8ba1f85 commit 511af60

File tree

1 file changed

+6
-4
lines changed
  • com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections

1 file changed

+6
-4
lines changed

com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ public NetworkList(IEnumerable<T> values = default,
6161
internal override void OnSpawned()
6262
{
6363
// If we are dirty and have write permissions by the time the NetworkObject
64-
// is finished spawning (same frame), then go ahead and reset the dirty related
65-
// properties for NetworkList in the event user script has made changes when
66-
// spawning to prevent duplicate entries.
67-
if (IsDirty() && CanSend())
64+
// is finished spawning (same frame) and the instance is on the spawn authority
65+
// side, then go ahead and reset the dirty related properties for NetworkList
66+
// in the event user script has made changes when spawning to prevent duplicate
67+
// entries (i.e. they are sent via CreateObjectMessage so we don't need to send
68+
// the NetworkVariableDeltaMessage.
69+
if (IsDirty() && CanSend() && m_NetworkBehaviour.HasAuthority)
6870
{
6971
UpdateLastSentTime();
7072
ResetDirty();

0 commit comments

Comments
 (0)