Player type

Options
In my game i have a class playertype which hold different type of player types like medic,scout etc.
I need a way to transmit player type to all players in room. Even new players who join game later need to know player types of char so that they can spawn appropiate chars.
Who do i do this

Thanks

Comments

  • Hi @sandy410,

    those are information you can for example store in the custom Player Properties. To do so you can use PUN's given functionality, for example when a player has selected his class:
    Hashtable props = new Hashtable {{"PlayerClass", "Medic"}};
    PhotonNetwork.player.SetCustomProperties(props);
    This way the information is also synchronized across all clients, even if they join later on. When this information arrives on a certain client, the following callback is called where you can work with the data:
    void OnPhotonPlayerPropertiesChanged(object[] playerAndUpdatedProps) {
        PhotonPlayer player = playerAndUpdatedProps[0] as PhotonPlayer;
        Hashtable props = playerAndUpdatedProps[1] as Hashtable;
        //...
    }
    If you however want to synchronize the entire PlayerType class, you have to register a Custom Type. To do so you can follow the Custom Types in C# section from this guide.
  • sandy410
    Options
    Thanks it works.