Player ID/viewID is

greelgreel
Hi,

I'm currently trying to assign unique colors to every player. Since every player should have the same color across all clients, i was thinking of using the photonview viewid/id. Sadly these id numbers will continue to increase every time someone joins.
I need to have a max ID of 8 (8 players max) so i can assign them as an index to my color array. Is there a built in photon feature that supports this or maybe someone has an idea how to it in some other way?

Thanks

Comments

  • Create an array, int[] idMap = new int[8]
    and then in idMap[0] through idMap[7] you store the IDs or better the PhotonPlayer of these 8 players and then simply find out who is who basing on this (you could use a Dictionary<int,PhotonPlayer> or <PhotonPlayer,Color> too)
  • You can make a room have a max of 8 players. This way, you never get into trouble because there is no color for someone else joining.

    ActorIDs will not change in a room. Even if player 4 leaves, this ID won't be re-used.
    But: If player 4 left, this color is available again. You could have a dictionary of colors and assign players to that (Dictionary<int, PhotonPlayer>). To access a player's color, you can also have a second dictionary for "player to color".
Sign In or Register to comment.