Search Unity

Character Selection inside the lobby in Lobby manager

Discussion in 'Connected Games' started by unity_uRfcUeY_GZR57A, Sep 12, 2019.

  1. unity_uRfcUeY_GZR57A

    unity_uRfcUeY_GZR57A

    Joined:
    Mar 14, 2019
    Posts:
    3
    Hello, I am new in unity, I started developing a lan multiplayer hide and seek using network lobby manager and network discovery. I have a sub panel UI for character selection in my lobby and a player list, when i tried to get inside the play scene character chosen by player was sync. my problem is when I'm trying the game in my android phone and to other phone it connects in lobby without problem but when in play scene the phone that act as host is not spawning his player prefab.

    p.s when i tried playing it in unity and connect it in my android phone it works fine.

    also it has a warning when i am choosing my character "trying to send command without authority"
     
  2. unity_uRfcUeY_GZR57A

    unity_uRfcUeY_GZR57A

    Joined:
    Mar 14, 2019
    Posts:
    3
    Here is my code in my lobby manager.



    Code (CSharp):
    1.  public override GameObject OnLobbyServerCreateLobbyPlayer(NetworkConnection conn, short playerControllerId)
    2.         {
    3.  
    4.             //this will list the players id joining the lobby.
    5.             Debug.Log("OnLobbyServerCreateLobbyPlayer: connection id is " + conn.connectionId);
    6.             if (!currentPlayers.ContainsKey(conn.connectionId))
    7.                 currentPlayers.Add(conn.connectionId, 0);
    8.             foreach(var player in currentPlayers)
    9.             {
    10.                 Debug.Log("OnLobbyServerCreateLobbyPlayer:currentPlayers are " + player);
    11.             }
    12.          
    13.             GameObject obj = Instantiate(lobbyPlayerPrefab.gameObject) as GameObject;
    14.             LobbyPlayer newPlayer = obj.GetComponent<LobbyPlayer>();
    15.             newPlayer.ToggleJoinButton(numPlayers + 1 >= minPlayers);
    16.  
    17.  
    18.             for (int i = 0; i < lobbySlots.Length; ++i)
    19.             {
    20.                 LobbyPlayer p = lobbySlots[i] as LobbyPlayer;
    21.  
    22.                 if (p != null)
    23.                 {
    24.                     p.RpcUpdateRemoveButton();
    25.                     p.ToggleJoinButton(numPlayers + 1 >= minPlayers);
    26.                 }
    27.             }
    28.  
    29.             return obj;
    30.         }
    31.        
    32.         public void SetupLocalPlayerCharacter(NetworkConnection conn, int character)
    33.         {
    34.             if (currentPlayers.ContainsKey(conn.connectionId))
    35.                 currentPlayers[conn.connectionId] = character;
    36.         }
    37.  
    38.         public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControllerId)
    39.         {
    40.             Debug.Log("OnLobbyServerCreateGamePlayer: connection id is " + conn.connectionId);
    41.             int index = currentPlayers[conn.connectionId];
    42.  
    43.             GameObject _playerCharacter = (GameObject)GameObject.Instantiate(spawnPrefabs[index], startPositions[conn.connectionId].position, Quaternion.identity);
    44.  
    45.             //NetworkServer.AddPlayerForConnection(conn, _playerCharacter, playerControllerId);
    46.  
    47.             return _playerCharacter;
    48.         }
    49.      
    50.  
    51.         public override void OnLobbyServerPlayerRemoved(NetworkConnection conn, short playerControllerId)
    52.         {
    53.             for (int i = 0; i < lobbySlots.Length; ++i)
    54.             {
    55.                 LobbyPlayer p = lobbySlots[i] as LobbyPlayer;
    56.  
    57.                 if (p != null)
    58.                 {
    59.                     p.RpcUpdateRemoveButton();
    60.                     p.ToggleJoinButton(numPlayers + 1 >= minPlayers);
    61.                 }
    62.             }
    63.         }
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    6,340
    The error "trying to send command without authority" means just that. On a client you called a Command, but the object you called it on was not allowed to call Commands from that client. Commands can only be called on a spawned GameObject when that client either has been assigned authority over that object by the server, or that object is the client's special Player GameObject.

    Sorry I don't know the rest since I never tried the lobby manager. Most people have walked away from Unet since it has been deprecated for a good while now, so you might have difficulty getting answers.
     
    zeeme0322 likes this.
  4. zeeme0322

    zeeme0322

    Joined:
    Sep 13, 2019
    Posts:
    3
    Thank you for replying.