Pass Data from NetworkLobbyPlayer to GamePlayer

Hello Folks,

I’m creating an RTS game with a lobby, in which the player can choose the spawnposition, faction, color and so on. My question is, how do you pass this information to the actual player pawn, when the instance gets created?

Best wishes
Nicolas

You need to extend the NetworkLobbyManager and override OnLobbyServerSceneLoadedForPlayer.

From the doc :
http://docs.unity3d.com/Manual/UNetLobby.html

    // for users to apply settings from their lobby player object to their in-game player object
    public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayer, GameObject gamePlayer)
    {
        var cc = lobbyPlayer.GetComponent<ColorControl>();
        var player = gamePlayer.GetComponent<Player>();
        player.myColor = cc.myColor;
        return true;
    }
1 Like