Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

isLocalPlayer always false for non-host players.

Discussion in 'Multiplayer' started by Ripper12345, May 20, 2017.

  1. Ripper12345

    Ripper12345

    Joined:
    Dec 6, 2016
    Posts:
    1
    My start function looks like this:
    upload_2017-5-20_13-11-19.png
    The rest of the script allows the player to shoot.

    I built the game, went back to Unity and hit play to host a game and the log gave what I wanted:
    upload_2017-5-20_13-12-48.png

    But once I try to join with the built game, I get a false response:
    upload_2017-5-20_13-14-4.png
    The bottom one being the isLocalPlayer value for the non-host player, so now one player can't shoot. I tried it with 3 players and it only is true for the host. I even quit the hosted game and joined again to see if the value might change, but it does not.

    Here is the Network settings for the Player GameObject, which the script is attached to:
    upload_2017-5-20_13-17-16.png

    This is the bullet Network settings, if it helps, which the script is NOT attached to:
    upload_2017-5-20_13-18-57.png

    I have been searching through google to find an answer and hours of doing so led me to nothing. If anyone knows a solution to my problem please let me know. Thank you!
     
  2. Dee0

    Dee0

    Joined:
    May 13, 2016
    Posts:
    1
    I'm having the same exact problem! The Host and Client both spawn player prefabs, i can move both players around with the movement correctly showing up on all screens, but isLocalPlayer always seems to be false on the joining client.
    Any luck on your side?
     
  3. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Well, if the host runs the client code then it will return false on their instance.
     
  4. greeneninjagames

    greeneninjagames

    Joined:
    Mar 23, 2017
    Posts:
    4
    So, I hit this issue today and through debug statements I figured out that OnStartLocalPlayer was happening AFTER OnEnable on the client and BEFORE OnEnable on the server.

    Once I figured that out, fixing was just a matter of making sure stuff was done in the correct order and such.