NetworkLobbyManager doesn't spawn player in the play scene.

I am not a very experienced programmer, and I’m not very good at spotting obvious mistakes, but when all my players are ready in the NetworkLobbyManager, it does move to the play scene for all players, however it does not spawn the player prefab when the scene is switched. Here is an image of the settings of my NetworkLobbyManager. I have used the default SendReadyToBeginMessage() method on the NetworkLobbyPlayer to determine when the settings are ready. Nothing appears in the console.

I would really appreciate it if someone could tell me if this is a bug, if I’m doing something wrong, or an alternative.



Ok, Looks like i’ve answered my own question.
I’ve looked at the source code for the NetworkLobbyManager, and seen that the method OnServerAddPlayer first checks to see if scene 0 is the “lobby scene” in the inspector, and if it isn’t, it returns. There was no handling for when the player is in the play scene though. So I copied the method from the source code, and put it in my own override method. Then I changed the code so that it checks for the current open scene, and if it name does not match the lobbyScene, instead of just returning, it spawns the playerprefab.

public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
        string name = SceneManager.GetActiveScene().name;
        if (name != this.lobbyScene)
            Debug.Log("We're in the play scene... Spawning player");
            //This means we're in the game scene
            var player = (GameObject)GameObject.Instantiate(playerPrefab, new Vector2(0, 0), Quaternion.identity);
            NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);

However, this does make an error appear:
ClientScene::AddPlayer: playerControllerId of 0 already in use.

This error hasn’t caused any issued though.

Even though I have solved this, please tell me if I’ve done something wrong, or if there are other ways of doing this.

@fredfishgames thank you! This seems like such a simple thing to need to do