com.unity.netcode.gameobjects
com.unity.netcode.gameobjects copied to clipboard
DontDestroyWithOwner not honored on PlayerObjects
Description
When a client disconnects from the server the server will destroy their PlayerObject regardless of how DontDestroyWithOwner is set.
Reproduce Steps
- Create a project with a simple Player Prefab configured.
- Set
DontDestroyWithOwner = trueon player prefabs when they're spawned. e.g. Add a component with the following to the prefab:
public override void OnNetworkSpawn()
{
base.OnNetworkSpawn();
NetworkObject.DontDestroyWithOwner = true;
}
- Launch a client and server.
- Close/disconnect the client.
Actual Outcome
The client prefab is destroyed on the server.
Expected Outcome
The client prefab is preserved on the server and ownership changes to the server.
Environment
- OS: macOS Monterey
- Unity Version: 2022.1.3f1
- Netcode Version: 1.0.0
- Netcode Commit: fddb7cd920e1db9e49d44846d7121e38f59bd137
Additional Context
NetworkManager.OnClientDisconnectFromServer doesn't check the field before destroying the PlayerObject.
Backlog: MTT-4458
This issue was resolved in #2225 and will be in the next update!