Giving instantiated objects a tag based on player ID?

Hi,

We've got a basic system done for distributing players to different rooms based on what gamemode they joined, but now we need to define teams. I will need to instantiate a couple of objects, and would like to tag them according to whether the player has an even or odd player ID(if player ID's are just counting from 1 and up, that is)
I believe we'd need to get the local player from the rooms playerlist in order to do so, but I'm not sure.
How would I get the playerlist for a room? Or does the PhotonPlayer class have some form of ID? What I need is an ID that for example, goes from 1-20, if the room contains 20 people. This ID needs to be established at the start of a game tho, and shouldn't change when a player leaves.

Comments

  • Photon has actorIDs. These are for players in a room. However, if someone leaves, the ID is not re-used (the objects and buffered messages still refer to the player how left) and you will get uneven teams using just this number.

    The player list is PhotonNetwork.playerList and the player's ID is simply: PhotonPlayer.ID.
    Ignoring the IDs you could go through the playerList on start and assign a team per player. If someone joins late, assign the team with lower "active" count.
  • Hmm okay, that should work. Still not entirely sure yet, but I guess I'll have to try some stuff out first.