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;
}