Hi there. I’m currently working on a multiplayer FPS game.
I am using custom properties to keep track of kills and deaths. It works pretty well, but sometimes it updates one without the other, and I can’t figure out why.
Here’s how I create the PhotonHashTable:
PhotonHashTable customProperties;
//---
customProperties = new PhotonHashTable();
customProperties.Add("Kills", KillCount);
customProperties.Add("Deaths", DeathCount);
PhotonNetwork.player.SetCustomProperties(customProperties);
And here is how it is updated:
public void AddjustCurrentHealth(int adj, PhotonView viewID) //, PhotonMessageInfo info)
{
currentHealth += adj;
if(currentHealth <= 0)
{
Killed(viewID);
}
}
void AddKillToScore(PhotonView viewID)
{
if (viewID.isMine)
sb.UpdateCustomProperty("Kills", 1);
}
void Killed(PhotonView viewID)
{
AddKillToScore(viewID);
if(photonView.isMine)
{
sb.UpdateCustomProperty("Deaths", 1);
}
}
I would think, that when the method “Killed” is called, it would update Kill count on the one who got the kill as well as update Death count on the guy who died. And it does, but sometimes twice for one of the two and sometimes only for either the kill or the death, not both.
Any help is much appreciated. Thank you.