Search Unity

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:
    3,066
    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,347
    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.