Skip to content

fix: inscene networkobjects get destroyed upon client networkmanager shutting down without connecting #1809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Mar 17, 2022

Any NetworkObjects living in a scene (or even DDOL) will get destroyed if during a client connection attempt, it fails or it gets cancelled.

NCCBUG-119

Changelog

com.unity.netcode.gameobjects

  • Fixed: in-scene NetworkObjects get destroyed if a client fails to connect and shuts down the NetworkManager.

Testing and Documentation

  • Includes an integration validation test.

This fixes the issue where if you attempt to connect as a client but never connect then in-scene placed NetworkObjects are destroyed.
validates the fix
white space fix
NoelStephensUnity and others added 4 commits March 17, 2022 17:27
Discovered that I needed to create a bit more of a unique test for this fix.
Reverting all changes to NetworkManagerTests and created new SceneObjectsNotDestroyedOnShutdownTest.
…-destroyed-upon-networkmanager-shuttingdown-without-connecting
…-destroyed-upon-networkmanager-shuttingdown-without-connecting
…-destroyed-upon-networkmanager-shuttingdown-without-connecting
@0xFA11 0xFA11 force-pushed the fix/nccbug-119-inscene-networkobjects-get-destroyed-upon-networkmanager-shuttingdown-without-connecting branch from a5b759a to 65d47a2 Compare March 18, 2022 18:27
@0xFA11 0xFA11 enabled auto-merge (squash) March 18, 2022 18:38
…d-upon-networkmanager-shuttingdown-without-connecting
@0xFA11 0xFA11 merged commit 0841a44 into develop Mar 18, 2022
@0xFA11 0xFA11 deleted the fix/nccbug-119-inscene-networkobjects-get-destroyed-upon-networkmanager-shuttingdown-without-connecting branch March 18, 2022 19:13
Copy link
Contributor

@mattwalsh-unity mattwalsh-unity left a comment

Choose a reason for hiding this comment

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

I think there might be a cleaner way than to rely on "IsSceneObject"'s nullness.

@@ -740,7 +740,7 @@ internal void DespawnAndDestroyNetworkObjects()

OnDespawnObject(networkObjects[i], shouldDestroy);
}
else
else if (networkObjects[i].IsSceneObject != null && !networkObjects[i].IsSceneObject.Value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth a comment for clarity of

"IsSceneObject will be null if I've never connected, or will be true (and stay true) if I've connected and am (and always will be) a scene object."

@agalloch21
Copy link

Hi, I've encountered the same issue using NGO 1.8.1 with a nearly blank project.

I notice that there was a change related to this section 6 months ago in commit 7ab9947. Could you please check it out?

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.

5 participants