com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

DontDestroyWithOwner not honored on PlayerObjects

Open JesseOlmer opened this issue 3 years ago • 1 comments

Description

When a client disconnects from the server the server will destroy their PlayerObject regardless of how DontDestroyWithOwner is set.

Reproduce Steps

  1. Create a project with a simple Player Prefab configured.
  2. 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;
    }
  1. Launch a client and server.
  2. 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.

JesseOlmer avatar Aug 22 '22 14:08 JesseOlmer

Backlog: MTT-4458

ashwinimurt avatar Aug 22 '22 20:08 ashwinimurt

This issue was resolved in #2225 and will be in the next update!

NoelStephensUnity avatar Sep 30 '22 21:09 NoelStephensUnity