Photon Unity Network. Accessing the same variable from different players.

Options
Hi. I am new to developing multiplayer games. I am using photon unity networking to develop a kind of 4 player chess game. When a player joins a room I want them to select a specific color for their pieces. But I want to avoid two players from having the same color. I have saved the color value in a string. And when a player joins the room I want them to access the string value for all other players in the room and compare it with their selection in order to stop them from choosing the same color as any other player in the room. Is there any way to access variables from other players in such a way. If not then can you guys suggest any other method to do that. Thankyou.

Comments

  • vadim
    Options
    Hi,

    Take a look at room custom properties. All clients share same room properties set.
    You may try player custom properties as well, but there is no guarantee that same property is different for different players.
  • Tobias
    Options
    There is a doc for Custom Properties online.
  • Does the GetComponent function work with the objects instantiated by other players in the scene?
  • vadim
    Options
    GetComponent is Unity's function which works for any object in scene including instantiated by PUN.