In-Scene NetworkObjects get destroyed if NetworkManager shuts down while not fully connected (e.g. failed connection attempt)
See original GitHub issueDescribe the bug Any NetworkObjects living in a scene (or even DDOL) will get destroyed if during connection attempt, it fails or it gets cancelled.
To Reproduce Steps to reproduce the behavior:
- Add a GameObject with a NetworkObject (Don’t Destroy With Owner =
true
) component to a scene. - Setup a NetworkManager with UNet’s transport.
- Start the scene in Play Mode.
- Start the NetworkManager as client, but don’t let it connect to a server.
- Shut down the NetworkManager.
Actual outcome The GameObject holding the NetworkObject is destroyed.
Expected outcome The GameObject holding the NetworkObject should only be despawned and it should eventually be destroyed when the scene is unloaded, not before.
Environment (please complete the following information):
- OS: Windows 10
- Unity Version: 2020.3
- Netcode Version: 1.0.0-pre.5
Additional context
During the connection attempt, the NetworkManager is in the following state: IsClient = true
, IsConnectedClient = false
. Every NetworkObjects are not yet spawned (IsSpawned = false
).
Then, a NetworkManager Shutdown
is done (because the connection attempt is cancelled or timed out).
NetworkManager’s ShutdownInternal
method is invoked, which then invokes NetworkSpawnManager’s DespawnAndDestroyNetworkObjects
method which - since those in-scene NetworkObjects aren’t spawned yet - fall into its else
case which Object.Destroy
them.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
@WhippetsAintDogs There seems to be an internal problem that prevented creating the Issue tracker for this particular bug. I have requested the customer QA teams to fix and have it created. I understand that not being able to easily search for an issue is a concern. We will discuss with the team. Thank you for the feedback.
Fixed in pre.7