Search Unity

isLocalPlayer always false in Awake() ?

Discussion in 'Multiplayer' started by hersheys72, Sep 11, 2015.

  1. hersheys72

    hersheys72

    Joined:
    Sep 4, 2015
    Posts:
    7
    I have a PlayerManager component attached to the player prefab

    void Awake ()
    {
    Debug.Log ("Awake Is Local Player: " + isLocalPlayer);
    // getComponents for variables
    }

    void Start ()
    {
    Debug.Log ("Start Is Local Player: " + isLocalPlayer);
    // Initial setup
    }

    the awake returns false, and true for the start function? Just found it odd as I was placing (!isLocalPlayer) return; and not expecting it to!
     
  2. TehGM

    TehGM

    Joined:
    Nov 15, 2013
    Posts:
    89
    Yes. It's always false on awake, as Awake is called as soon as the class is initialized, so it has no time for network-related stuff yet.
    You can use OnStartLocalPlayer. I did not check if it's called on non-owner clients though.
     
    Jekt31 and hersheys72 like this.