Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.15k stars 435 forks source link

Cancelling client's connection results in scene network objects to be destroyed #2917

Closed NaolShow closed 6 months ago

NaolShow commented 6 months ago

Description

It seems that a regression occured between the version v1.7.1 and v1.8.0 (reproductible up until the v1.9.1) that affects the scene network objects.

When starting a client connection (to an unreachable IP to test the bug) and then cancelling the connection with NetworkManager.Shutdown(true or false) will result in ALL the scene network object to be destroyed. Those objects do not reappear after connecting/hosting again.

Reproduce Steps

  1. Create a random network object in a scene
  2. Connect as a client in the same scene
  3. Cancel the connection

Actual Outcome

The scene network object is destroyed from the scene

Expected Outcome

The scene network object should stay in the scene, only be resetted for the next time when hosting or connecting again as a client

Environment

Additional Context

Regression must have come from one of the commits made between the v1.7.1 and v1.8.0: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/compare/release/1.7.1...ngo/1.8.0

I'll try to crawl through the problem when I'll have time.

EDIT: Quick check leads to the culprit which is this commit: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/commit/7ab9947497f39fe2d966f70822718845de5d8436