StopHost(), StopClient() and StopServer() missing

Hello,

I am reading Netcode for GameObjects 1.0.0 documentation and I found this example: https://docs-multiplayer.unity3d.com/docs/components/networkmanager/ (Disconnect section). I am trying to make disconnect button, but it seems like this example is outdated and I can’t find how to Stop the Host or Client. What is the current method of doing this?

public void Leave()
    {     
        if (NetworkManager.Singleton.IsHost)
        {
            NetworkManager.Singleton.StopHost();
            NetworkManager.Singleton.ConnectionApprovalCallback -= ApprovalCheck;
        }
        else if (NetworkManager.Singleton.IsClient)
        {
            NetworkManager.Singleton.StopClient();
        }

        connectionPannel.SetActive(true);
        leaveButton.SetActive(false);
    }

I’m running into this too.

From the 2021-10-19 changelog:

Removed NetworkManager’s StopServer(), StopClient() and StopHost() methods and replaced with single NetworkManager.Shutdown() method for all (#1108)

I’ve replaced the methods with the Shutdown() method, now when a client disconnects, client-owned gameobjects are not unspawning automatically. I’m wondering if this is a bug or if I’m just misunderstanding the documentation.

Any help on the spawning issue would be appreciated.

3 Likes

You have to uncheck "Don’t destroy with owner from the NetworkObject script attached to the player prefab(assuming you have one).

2 Likes