Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Unity Multiplayer isLocalPlayer initially returns false when player reconnects to server

Discussion in 'Multiplayer' started by TheLastVertex, Mar 23, 2020.

  1. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    I am trying to implement the ability for players to reconnect to a dedicated server if they lose connection. I am currently not destroying the player object when they disconnect, and successfully assigning control back to the existing object when they reconnect.

    When the player re-establishes their connection, the objects they control initially return "isLocalPlayer" as false. This results in camera's and other per player objects being disabled during awake/start logic. This flag does eventually return true but only after a couple frame updates.

    Is there a callback or a way to check globally if this part of the process is completed? This way I could just manually trigger the setup logic once I know this flag is correct.
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,991
    Which networking solution do you use? Unity's built in (as the flag suggests)?
     
  3. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    Unet HLAPI.
     
  4. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,299
    Both UNET's state reset and reassigning authority (I assume that's what you do?) are full of bugs.
    Try Mirror: https://github.com/vis2k/Mirror it's an open source UNET fork with 3447 improvements :)
     
    Joe-Censored likes this.