Synchronising weapons using CustomPlayerProperties?
Options
Hey, i'm trying to synchronise each player's loadout between them and the system I'm using uses CustomPlayerProperties. Here's what I've got now:
This is the SetupWeapons() method:
I'm a bit stuck as this is done when the player spawns, so later players don't get this. Any help? I essentially just want to send the weapon property on start, and for other players to get it.
void Start() { //Set the weapon properties SetupWeapons(); }
This is the SetupWeapons() method:
public void SetupWeapons() { if(view.isMine) { //Basically cramming everything into one string. //Should look like BODY:(body)|BARREL:(barrel)|OB:(overbarrel)|UB:(underbarrel) string WeaponString = "BODY:" + WeaponManager.instance.ourWeapon.body + "|" + "BARREL:" + WeaponManager.instance.ourWeapon.barrel; if (WeaponManager.instance.ourWeapon.overBarrel != null) { WeaponString += "|OB:" + WeaponManager.instance.ourWeapon.overBarrel; } if (WeaponManager.instance.ourWeapon.underBarrel != null) { WeaponString += "|UB:" + WeaponManager.instance.ourWeapon.underBarrel; } ExitGames.Client.Photon.Hashtable props = new ExitGames.Client.Photon.Hashtable(); props.Add("Weapon 1", WeaponString); PhotonNetwork.player.SetCustomProperties(props); //LoadWeapon((string)view.owner.CustomProperties["Weapon 1"]); } }
I'm a bit stuck as this is done when the player spawns, so later players don't get this. Any help? I essentially just want to send the weapon property on start, and for other players to get it.
0
Answers
-
Then, to get the properties, it uses OnPhotonPlayerPropertiesUpdate() to get the property for the weapon and instantiate the parts.
public override void OnPhotonPlayerPropertiesChanged(object[] changedProps) { PhotonPlayer player = changedProps[0] as PhotonPlayer; print(player.NickName); ExitGames.Client.Photon.Hashtable props = changedProps[1] as ExitGames.Client.Photon.Hashtable; //Is the prop's owner us? if (view.owner == player) weapnDebugText.text = props["Weapon 1"].ToString(); //set the text above our head to our weapon string, debugging purposes //{ // //If so, load the weapon // ExitGames.Client.Photon.Hashtable props = changedProps[1] as ExitGames.Client.Photon.Hashtable; //} }
for some reason, the guy who joins after doesn't get his text updated?0 -
bump0