@@ -1622,13 +1622,11 @@ internal void OnDespawnObject(NetworkObject networkObject, bool destroyGameObjec
16221622 }
16231623
16241624 var distributedAuthority = NetworkManager . DistributedAuthorityMode ;
1625- var hasDAAuthority = distributedAuthority && ( networkObject . HasAuthority || ( NetworkManager . DAHost && authorityOverride ) ) ;
1626- var hasClientServerAuthority = ! distributedAuthority && NetworkManager . IsServer ;
1627- var hasAuthority = hasDAAuthority || hasClientServerAuthority ;
16281625
16291626 // If we are shutting down the NetworkManager, then ignore resetting the parent
1630- // and only attempt to remove the child's parent on the server-side
1631- if ( ! NetworkManager . ShutdownInProgress && hasAuthority )
1627+ // Remove the child's parent server-side or in distributedAuthorityMode
1628+ // DistributedAuthorityMode: All clients need to remove the parent locally due to mixed-authority hierarchies and race-conditions
1629+ if ( ! NetworkManager . ShutdownInProgress && ( NetworkManager . IsServer || distributedAuthority ) )
16321630 {
16331631 if ( destroyGameObject && networkObject . IsSceneObject == true && ! NetworkManager . SceneManager . IsSceneUnloading ( networkObject ) )
16341632 {
@@ -1654,7 +1652,7 @@ internal void OnDespawnObject(NetworkObject networkObject, bool destroyGameObjec
16541652 }
16551653 // For mixed authority hierarchies, if the parent is despawned then any removal of children
16561654 // is considered "authority approved". Set the AuthorityAppliedParenting flag.
1657- spawnedNetObj . AuthorityAppliedParenting = authorityOverride ;
1655+ spawnedNetObj . AuthorityAppliedParenting = distributedAuthority && ! networkObject . HasAuthority ;
16581656
16591657 // Try to remove the parent using the cached WorldPositionStays value
16601658 // Note: WorldPositionStays will still default to true if this was an
@@ -1677,7 +1675,12 @@ internal void OnDespawnObject(NetworkObject networkObject, bool destroyGameObjec
16771675
16781676 networkObject . InvokeBehaviourNetworkDespawn ( ) ;
16791677
1680- if ( ! NetworkManager . ShutdownInProgress && hasAuthority )
1678+ // Whether we are in distributedAuthority mode and have authority on this object
1679+ var hasDAAuthority = distributedAuthority && ( networkObject . HasAuthority || ( NetworkManager . DAHost && authorityOverride ) ) ;
1680+
1681+ // Don't send messages if shutting down
1682+ // Otherwise send messages if we are the authority (either the server, or the DA mode authority of this object).
1683+ if ( ! NetworkManager . ShutdownInProgress && ( hasDAAuthority || ( ! distributedAuthority && NetworkManager . IsServer ) ) )
16811684 {
16821685 if ( NetworkManager . NetworkConfig . RecycleNetworkIds )
16831686 {
@@ -1692,7 +1695,6 @@ internal void OnDespawnObject(NetworkObject networkObject, bool destroyGameObjec
16921695 /*
16931696 * Configure message targets
16941697 */
1695-
16961698 // If we are using distributed authority and are not the DAHost, send a message to the Server (CMBService or DAHost)
16971699 if ( hasDAAuthority && ! NetworkManager . DAHost )
16981700 {
0 commit comments