In what order is PhotonNetwork.playerList in?
Options
Comments
-
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?0 -
Im trying to get the name of player 3... AKA the third one to join the room, any ideas?
-MileSplit the Code Runner0 -
Sorry, just found the PhotonPLayer.find...0
-
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.0 -
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);
}
}0 -
Hi @daggasoft,
I think you are trying to re-invent the wheel.
PUN already keeps the list of players for you.0 -
Creating our own list can be usefull to identify a player ?
Because the player.ID cant be unallocate if someone leave the room0