Updating character equipment

Options
I am trying to sync character look across server. I have some client sided functions that sets the gear according to it's logged in character. What im struggling with is updating the look of that character across all clients. I have it now so it sets your character but you cannot see the proper look on the other client and vice versa. I wrote a function (RPC) which I thought would do the trick but apparently isn't. Is RPC's the best way of going about this? Or could custom properties be more efficient. I have been stuck on this for some time and it's really holding me back. Im looking for a bit on insight as to why what i'm doing isn't working and how I can make it work. Any help is appreciated.

My Code regarding setting player equipment.

I locally set the equipment after instantiation then call this RPC.

equipment.GetComponent ().RPC ("UpdateCharacterEquipmentOnServer", PhotonTargets.Others);

[PunRPC]
public void UpdateCharacterEquipmentOnServer(PhotonMessageInfo info)
{
NetworkCharacter myCharacter = GetComponent ();

Debug.Log (myCharacter.CharacterName);

foreach (int equip_id in myCharacter.EquipmentIds)
{
if (equip_id != 0)
{
SetEquipment(EquipmentIndex.GetEquipmentById(equip_id));
}
}
}


My thinking with this was that because i locally set gear, then call this RPC to other clients, it would set their gear on my instance to display what they really have on,

Thanks,
Dev.

Comments

  • Dev
    Options
    So what i ended up trying after before joining the room was setting a custom property for each equipment id from then i set it once in the room - however im still having trouble with other players seeing the equipment. It is displaying the other characters with the default gear instead of the gear that is supposed to be loaded onto the character.
  • Tobias
    Options
    It sounds like you're missing some update or read other props you set. Using the same keys can be tricky, if you don't use constants, e.g..
    Hope you find it.