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 = true on 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: fddb7cd
Additional Context
NetworkManager.OnClientDisconnectFromServer doesn't check the field before destroying the PlayerObject.
Description
When a client disconnects from the server the server will destroy their PlayerObject regardless of how DontDestroyWithOwner is set.
Reproduce Steps
DontDestroyWithOwner = trueon player prefabs when they're spawned. e.g. Add a component with the following to the prefab: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
Additional Context
NetworkManager.OnClientDisconnectFromServerdoesn't check the field before destroying the PlayerObject.