Search Unity

2 same playerControlerId's

Discussion in 'Multiplayer' started by tleon, Sep 5, 2016.

  1. tleon

    tleon

    Joined:
    Sep 15, 2013
    Posts:
    12
    I'm developing Unity multiplayer game. I'm testing my game locally and it all works fine except when new player tries to join game I get this error message:

    On host side:

    Thereis already a player at that playerControllerId forthis connections.
    On client side:

    A connection has already been setas ready.There can only be one.
    Player are autospawn by NetworkManager, this is code that extends manager to UI.

    Code (CSharp):
    1. publicclassNetwotkManagerCustom:NetworkManager{
    2.  
    3.        publicNetworkDiscoveryDiscovery;
    4.        publicGameObjectPlayerPrefab;
    5.  
    6.        publicvoidStartHost(){
    7.                SetPort();
    8.               NetworkManager.singleton.StartHost();
    9.               Discovery.Initialize();
    10.               Discovery.StartAsServer();
    11.        }
    12.  
    13.        publicvoidSearchGame(){
    14.               Discovery.Initialize();
    15.               Discovery.StartAsClient();
    16.        }
    17.  
    18.        publicoverridevoidOnClientConnect(NetworkConnection connection){
    19.               ClientScene.AddPlayer(connection,0);
    20.        }
    21. }
    If I "pause" the game when there are both players in the scene(second before error) and if I go to Network Identity of player they both have they identities set to "0".

    Why is this error happening?
     
    Last edited: Sep 6, 2016