Skip to content

fix: respawn hybrid NetworkObject on NetworkShow after NetworkHide - #4236

Merged
NoelStephensUnity merged 2 commits into
develop-3.x.xfrom
fix/hybrid-hide-show-respawn
Oct 30, 2026
Merged

NoelStephensUnity merged 2 commits into
develop-3.x.xfrom
fix/hybrid-hide-show-respawn

Conversation

@NoelStephensUnity

@NoelStephensUnity NoelStephensUnity commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Purpose of this PR

A hybrid (NetworkObject + GhostObject) instance hidden from a client with NetworkHide and then shown again with NetworkShow is now respawned on that client, under both client-server topologies (UnifiedHost and UnifiedServer). Before this, the CreateObjectMessage sent by NetworkShow waited for a ghost spawn that never arrived and the instance was never respawned.

On a client, despawning a hybrid NetworkObject leaves its GameObject to N4E, and NetworkHide does not make the ghost irrelevant, so the instance survives. Its pending ghost spawn entry was consumed on the first spawn, so the show had nothing to match against. The client now re-registers the surviving instance as a pending ghost spawn when it is despawned; NetworkObject.OnDestroy already drops that entry if N4E later destroys the ghost.

This also unblocks the Unified fixtures of NetworkListTests.NetworkShowWithThrottledPendingChanges in #4216.

PR Scope:

  • NetworkSpawnManager: a client re-registers a despawned hybrid instance as a pending ghost spawn and clears its destroying flag, so its NetworkBehaviours (e.g. AttachableBehaviour detach) work again once shown.
  • GhostSpawnManager: only a root instance is moved into the active scene on spawn, so a hidden child parented by NGO can be shown again.
  • New HybridNetworkShowHideTests (UnifiedHost and UnifiedServer): hide/show cycles respawn the same instance, a parented child keeps its parent, attach/detach works after a show, and despawning while hidden releases the pending entry.

Out of scope:

  • A hidden hybrid instance still exists on the client and keeps receiving N4E updates, unlike a hidden NGO-only object. (Removing it requires N4E ghost relevancy driven by NGO observers, which is follow-up work.)

Jira ticket

N/A

Changelog

None (hybrid mode is experimental).

Documentation

  • No documentation changes or additions were necessary.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

If any boxes above are checked the QA team will be automatically added as a PR reviewer.

Up-port

N/A (hybrid mode exists on develop-3.x.x only).

Backports

N/A (hybrid mode exists on develop-3.x.x only).

On a client, despawning a hybrid NetworkObject leaves its GameObject to N4E,
and NetworkHide does not make the ghost irrelevant, so the instance survives.
Its pending ghost spawn entry was consumed on first spawn, so the CreateObjectMessage
sent by NetworkShow waited for a ghost spawn that never came.

The client now re-registers the surviving instance as a pending ghost spawn;
NetworkObject.OnDestroy already drops the entry if N4E later destroys it.

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Harness Review

Needs changes

The pending-ghost registration addresses the missing respawn, but the reused-instance path still fails for supported hierarchy and component configurations.

Reviewed commit 2ac277f

🤖 Helpful? 👍/👎

@codecov-github-com

codecov-github-com Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
....netcode.gameobjects/Runtime/Core/NetworkObject.cs 0.00% 10 Missing ⚠️
...ameobjects/Runtime/Spawning/NetworkSpawnManager.cs 0.00% 5 Missing ⚠️
....gameobjects/Runtime/Spawning/GhostSpawnManager.cs 0.00% 4 Missing ⚠️
...tcode.gameobjects/Runtime/Core/NetworkBehaviour.cs 0.00% 3 Missing ⚠️
@@                Coverage Diff                @@
##           develop-3.x.x    #4236      +/-   ##
=================================================
- Coverage          76.91%   76.84%   -0.07%     
=================================================
  Files                159      159              
  Lines              27603    27624      +21     
=================================================
- Hits               21230    21229       -1     
- Misses              6373     6395      +22     
Flag Coverage Δ
NGOv2_project_testproject_ubuntu 75.92% <0.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...tcode.gameobjects/Runtime/Core/NetworkBehaviour.cs 84.97% <0.00%> (-0.31%) ⬇️
....gameobjects/Runtime/Spawning/GhostSpawnManager.cs 8.96% <0.00%> (-0.19%) ⬇️
...ameobjects/Runtime/Spawning/NetworkSpawnManager.cs 71.22% <0.00%> (-0.25%) ⬇️
....netcode.gameobjects/Runtime/Core/NetworkObject.cs 72.28% <0.00%> (-0.37%) ⬇️

... and 1 file with indirect coverage changes

Components Coverage Δ
com.unity.netcode.gameobjects 76.84% <0.00%> (-0.07%) ⬇️

ℹ️ Need help interpreting these results?

The despawn on NetworkHide marks the instance and its NetworkBehaviours as destroying,
which stuck once the instance survived, so AttachableBehaviour could no longer detach on
the client. The surviving instance now clears that flag.

A retained child that NGO parented is no longer a root GameObject, so NetworkShow threw
in MoveGameObjectToScene. Only root instances are moved into the active scene.
@NoelStephensUnity
NoelStephensUnity enabled auto-merge (squash) October 30, 2026 14:15
@NoelStephensUnity
NoelStephensUnity merged commit c79b7eb into develop-3.x.x Oct 30, 2026
29 of 30 checks passed
@NoelStephensUnity
NoelStephensUnity deleted the fix/hybrid-hide-show-respawn branch October 30, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants