In what order is PhotonNetwork.playerList in?

Options
I was wondering in what order is PhotonNetwork.playerList in? I would think it would be in Actor ID order with the Master client being first, but it dosent seem to be so... Could somone shed some light on this? ;)

Comments

  • vadim
    Options
    Players in PhotonNetwork.playerList are not ordered in any sensible way, they are just random. So you can't get any use of it.
    But why do you need that order? What are you trying to do?
  • Im trying to get the name of player 3... AKA the third one to join the room, any ideas?
    -MileSplit the Code Runner
  • Sorry, just found the PhotonPLayer.find...
  • vadim
    Options
    Yes. PhotonPLayer.find returns player with specified actor Id.
    Actor id is just an unique id and is not necessarily the position in room joining sequence. But looks like it is for current server realization (but not guarantied to be always so).
    At least you may be always sure that id's only increment for new actors and id's of left actors are never reused.
  • daggasoft
    Options
    This is super old but I had the same need to know whos who without any guaranteed order from photon. So I maintain my own list in my game manager script. I'm brand new to photon so maybe this is stupid or not necessary.

    //Defined at top of class
    public List UserQueue;

    //Included in class and called by OnPhotonPlayerConnected, OnPhotonPlayerDisconnected, CreateRoom
    void UpdateRoomStateWhenPlayerJoinsOrLeaves(PhotonPlayer player, bool joined){

    if (!PhotonNetwork.isMasterClient)
    {
    return;
    }

    if (joined)
    {
    UserQueue.Add(player.ID);
    }
    else {
    UserQueue.Remove(player.ID);
    }
    }
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @daggasoft,

    I think you are trying to re-invent the wheel.
    PUN already keeps the list of players for you.
  • M4TT
    Options
    Creating our own list can be usefull to identify a player ?
    Because the player.ID cant be unallocate if someone leave the room