Search Unity

Question The error - "There is already a player for this connection" when using Mirror

Discussion in 'Multiplayer' started by umarautarhanov, Jan 4, 2024.

  1. umarautarhanov

    umarautarhanov

    Joined:
    Aug 23, 2023
    Posts:
    4
    Hello! Can somebody help finding a solution to the problem. So I am developing a multiplayer game using Mirror for networking. I have for now 2 scenes. 1 being an online lobby scene and the next being a online map scene. I want the server to be changing the maps dynamically from one scene to another for all the clients.

    This works well when the clients connect to the lobby scene. And only then the Server changes the scene. However, when the client tries to join the online map scene AFTER the server has changed the scene, the server shows an error "There is already a player for this connection". And therefore, the client cannot join.

    I use the following simple code to change the scene. The method LoadScene() is attached to a button and is run on the server instance.

    Code (CSharp):
    1.  
    2.  
    3. public void LoadScene()
    4. {
    5.     if (isServer)
    6.     {
    7.         manager.ServerChangeScene("TestMapScene");
    8.     }
    9. }
    10.  
    Снимок экрана 2024-01-05 005752.png