@@ -2961,7 +2961,7 @@ internal bool InitializeChildNetworkBehaviours()
29612961 /// </remarks>
29622962 /// <param name="originalOwnerId">the owner prior to beginning the change in ownership change.</param>
29632963 /// <param name="originalPreviousOwnerId">the previous owner prior to beginning the change in ownership change.</param>
2964- internal void SynchronizeOwnerNetworkVariables ( ulong originalOwnerId , ulong originalPreviousOwnerId )
2964+ internal void SynchronizeOwnerNetworkVariables ( ulong originalOwnerId , ulong originalPreviousOwnerId , bool authorityChangedOwnership = false )
29652965 {
29662966 var currentOwnerId = OwnerClientId ;
29672967 OwnerClientId = originalOwnerId ;
@@ -2971,17 +2971,31 @@ internal void SynchronizeOwnerNetworkVariables(ulong originalOwnerId, ulong orig
29712971 childBehaviour . MarkOwnerReadDirtyAndCheckOwnerWriteIsDirty ( ) ;
29722972 }
29732973
2974+ // If the spawn authority of a distributed authority network topology has invoked a change in ownership,
2975+ // then we want to invoke the NetworkBehaviourUpdate prior to changing the owner back.
2976+ if ( authorityChangedOwnership && NetworkManager . DistributedAuthorityMode )
2977+ {
2978+ // Force send a state update for all owner read NetworkVariables and any currently dirty
2979+ // owner write NetworkVariables.
2980+ NetworkManagerOwner . BehaviourUpdater . NetworkBehaviourUpdate ( true ) ;
2981+ }
2982+
29742983 // Now set the new owner and previous owner identifiers back to their original new values
2975- // before we run the NetworkBehaviourUpdate. For owner read only permissions this order of
2976- // operations is **particularly important** as we need to first (above) mark things as dirty
2977- // from the context of the original owner and then second (below) we need to send the messages
2978- // which requires the new owner to be set for owner read permission NetworkVariables.
2984+ // after we run the NetworkBehaviourUpdate.
29792985 OwnerClientId = currentOwnerId ;
29802986 PreviousOwnerId = originalOwnerId ;
29812987
2982- // Force send a state update for all owner read NetworkVariables and any currently dirty
2983- // owner write NetworkVariables.
2984- NetworkManagerOwner . BehaviourUpdater . NetworkBehaviourUpdate ( true ) ;
2988+ // For owner read only permissions this order of operations is **particularly important** as
2989+ // we need to first (above) mark things as dirty from the context of the original owner and
2990+ // then second (below) we need to send the messages which requires the new owner to be set.
2991+ // Note: Owner read only NetworkVariables do not make sense in a distributed authority topology
2992+ // since the only instance that can write is the owner.
2993+ if ( ! NetworkManager . DistributedAuthorityMode )
2994+ {
2995+ // Force send a state update for all owner read NetworkVariables and any currently dirty
2996+ // owner write NetworkVariables.
2997+ NetworkManagerOwner . BehaviourUpdater . NetworkBehaviourUpdate ( true ) ;
2998+ }
29852999 }
29863000
29873001 // NGO currently guarantees that the client will receive spawn data for all objects in one network tick.
0 commit comments