Skip to content

Commit a73b597

Browse files
update
Applying suggested adjustment to logic within OnNetworkPreDespawn.
1 parent 6daf3ea commit a73b597

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

com.unity.netcode.gameobjects/Runtime/Components/Helpers/AttachableNode.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,15 @@ public override void OnNetworkPreDespawn()
7676
{
7777
continue;
7878
}
79-
// If we don't have authority but should detach on despawn,
80-
// then proceed to detach.
81-
if (!attachable.HasAuthority)
79+
80+
if (attachable.HasAuthority && attachable.IsSpawned)
8281
{
83-
attachable.ForceDetach();
82+
// Detach the normal way with authority
83+
attachable.Detach();
8484
}
85-
else
85+
else if (!attachable.HasAuthority || !attachable.IsDestroying)
8686
{
87-
if (attachable.IsSpawned)
88-
{
89-
// Detach the normal way with authority
90-
attachable.Detach();
91-
}
92-
else if (!attachable.IsDestroying)
93-
{
94-
attachable.ForceDetach();
95-
}
87+
attachable.ForceDetach();
9688
}
9789
}
9890
}

0 commit comments

Comments
 (0)