Network Lobby Manager Spawn Selected Prefab for Client

Hi,
I want make each client can select their player prefab in lobby and when game start i want instantiate selected prefab for client.I define varible in LobbyManager but its not working.Its always same with host.How can i make this ?

Edit: I solved with this code.But i dont know is it good or bad way.

  public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayer, GameObject gamePlayer)
        {
            //This hook allows you to apply state data from the lobby-player to the game-player
            //just subclass "LobbyHook" and add it to the lobby object.

            if (_lobbyHooks)
                _lobbyHooks.OnLobbyServerSceneLoadedForPlayer(this, lobbyPlayer, gamePlayer);

            int prefabIndex = lobbyPlayer.GetComponent<LobbyPlayer>().prefabIndex;
            Debug.LogError("Prefab Index:" + spawnPrefabs[prefabIndex].name);

            GameObject playerPrefab = (GameObject)Instantiate(spawnPrefabs[prefabIndex]);
            //gamePlayer = playerPrefab;
          //  NetworkServer.Spawn(playerPrefab);
            NetworkServer.AddPlayerForConnection(
                lobbyPlayer.GetComponent<NetworkIdentity>().connectionToClient, playerPrefab,(short)Random.Range(0,32));
            return true;
        }

Thanks for this, but when i use this method it spawns two playerobjects per client.
Any way to fix that?

Hey Dude I dont know if your problem is still recent or if youre still interested in this topic, but I have found a viable solution for that problem.

Documentation links:
https://docs.unity3d.com/ScriptReference/Networking.NetworkLobbyManager.html (useful overview)
https://docs.unity3d.com/ScriptReference/Networking.NetworkLobbyManager.OnLobbyServerCreateGamePlayer.html (the method to use)
The API doesnt get into too much detail but it was enough for me to figure out how it works. Below is a blog post by a guy who had a similiar problem and gives some more explanatory.

https://abrgame.blogspot.de/2016/01/using-unet-to-spawn-different-player.html?showComment=1467227533786

If you have any more questions, feel free to ask me! :slight_smile:

Sorry to bumb an old thread! But I was following the link in the blogspot and found implemented it into my LobbyManager. But I encountered a weird error where it throws a weird outofrange error when trying to get the prefabs from spawnprefabs[ ]. Have checked that I added the relevant prefabs in the spawnable section, so kinda at a lost now :confused: hope someone can help!