@@ -1622,13 +1622,11 @@ internal void OnDespawnObject(NetworkObject networkObject, bool destroyGameObjec
1622
1622
}
1623
1623
1624
1624
var distributedAuthority = NetworkManager . DistributedAuthorityMode ;
1625
- var hasDAAuthority = distributedAuthority && ( networkObject . HasAuthority || ( NetworkManager . DAHost && authorityOverride ) ) ;
1626
- var hasClientServerAuthority = ! distributedAuthority && NetworkManager . IsServer ;
1627
- var hasAuthority = hasDAAuthority || hasClientServerAuthority ;
1628
1625
1629
1626
// 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 ) )
1632
1630
{
1633
1631
if ( destroyGameObject && networkObject . IsSceneObject == true && ! NetworkManager . SceneManager . IsSceneUnloading ( networkObject ) )
1634
1632
{
@@ -1654,7 +1652,7 @@ internal void OnDespawnObject(NetworkObject networkObject, bool destroyGameObjec
1654
1652
}
1655
1653
// For mixed authority hierarchies, if the parent is despawned then any removal of children
1656
1654
// is considered "authority approved". Set the AuthorityAppliedParenting flag.
1657
- spawnedNetObj . AuthorityAppliedParenting = authorityOverride ;
1655
+ spawnedNetObj . AuthorityAppliedParenting = distributedAuthority && ! networkObject . HasAuthority ;
1658
1656
1659
1657
// Try to remove the parent using the cached WorldPositionStays value
1660
1658
// Note: WorldPositionStays will still default to true if this was an
@@ -1677,7 +1675,12 @@ internal void OnDespawnObject(NetworkObject networkObject, bool destroyGameObjec
1677
1675
1678
1676
networkObject . InvokeBehaviourNetworkDespawn ( ) ;
1679
1677
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 ) ) )
1681
1684
{
1682
1685
if ( NetworkManager . NetworkConfig . RecycleNetworkIds )
1683
1686
{
@@ -1692,7 +1695,6 @@ internal void OnDespawnObject(NetworkObject networkObject, bool destroyGameObjec
1692
1695
/*
1693
1696
* Configure message targets
1694
1697
*/
1695
-
1696
1698
// If we are using distributed authority and are not the DAHost, send a message to the Server (CMBService or DAHost)
1697
1699
if ( hasDAAuthority && ! NetworkManager . DAHost )
1698
1700
{
0 commit comments