File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
com.unity.netcode.gameobjects/Runtime/NetworkVariable Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -61,17 +61,17 @@ public NetworkList(IEnumerable<T> values = default,
6161 internal override void OnSpawned ( )
6262 {
6363 // If the NetworkList is:
64+ // - On the spawn authority side.
6465 // - Dirty
6566 // - State updates can be sent:
6667 // -- The instance has write permissions.
6768 // -- The last sent time plus the max send time period is less than the current time.
6869 // - User script has modified the list during spawn.
69- // - This instance is on the spawn authority side.
7070 // When the NetworkObject is finished spawning (on the same frame), go ahead and reset
7171 // the dirty related properties and last sent time to prevent duplicate entries from
7272 // being sent (i.e. CreateObjectMessage will contain the changes so we don't need to
7373 // send a proceeding NetworkVariableDeltaMessage).
74- if ( IsDirty ( ) && CanSend ( ) && m_NetworkObject . IsSpawnAuthority )
74+ if ( m_NetworkObject . IsSpawnAuthority && IsDirty ( ) && CanWrite ( ) && CanSend ( ) )
7575 {
7676 UpdateLastSentTime ( ) ;
7777 ResetDirty ( ) ;
Original file line number Diff line number Diff line change @@ -413,9 +413,18 @@ internal override void WriteFieldSynchronization(FastBufferWriter writer)
413413 /// </summary>
414414 internal override void OnSpawned ( )
415415 {
416- // Assure any changes made to this NetworkVariable during spawn or post-spawn are
417- // serialized with the CreateObjectMessage.
418- if ( IsDirty ( ) && CanSend ( ) )
416+ // If the NetworkVariable is:
417+ // - On the spawn authority side.
418+ // - Dirty.
419+ // - State updates can be sent:
420+ // -- The instance has write permissions.
421+ // -- The last sent time plus the max send time period is less than the current time.
422+ // - User script has modified the list during spawn.
423+ // When the NetworkObject is finished spawning (on the same frame), go ahead and reset
424+ // the dirty related properties and last sent time to prevent duplicate updates from
425+ // being sent (i.e. CreateObjectMessage will contain the changes so we don't need to
426+ // send a proceeding NetworkVariableDeltaMessage).
427+ if ( m_NetworkObject . IsSpawnAuthority && IsDirty ( ) && CanWrite ( ) && CanSend ( ) )
419428 {
420429 UpdateLastSentTime ( ) ;
421430 ResetDirty ( ) ;
You can’t perform that action at this time.
0 commit comments