the best way to sync health exactly in photon

im making a realtime online MOBA game. in this game, there is monsters, minions and more.
but if i make the client give damage to monsters and send it to server, players doesnt get synced exactly, like if they give last damage to the same monster at the same time, both of player will be able to get gold
,and i dont want this. so i made it to send the attack data to masterclient and give damage in masterclient and send this data to all other clients. then it is synced exactly, but its delay of sending many RPC(I dont know the exact reason but its delaying about 0.5~1 seconds) is a bit critical to my game.

so i want to know if there is a faster way to sync health with keeping it synced.

my damage syncing script =

	//when client attacks
photonView.RPC("GiveDamageRPC",PhotonTargets.MasterClient,new object[]{GetDamage,hitter.name});

	[PunRPC]
	void GiveDamageRPC(float GetDamage,string _hitterName)
	{
		LastDamager = GameObject.Find(_hitterName);
		CurHP -= GetDamage;
photonView.RPC("SyncHPBeta",PhotonTargets.Others,new object[]{CurHP});
	}

[PunRPC]
void SyncHPBeta(float HB)
{
	CurHP = HB;
}

Hi,

I would simply put the damage my character dealt in an RPC, like this: photonView.RPC("DealDamage", PhotonTargets.All, damage); // damage is the amount of damage dealt. This way, each client in the room can update the health value of the object on their own. Since each client will only subtract a certain amount from the health value, the order of the messages is irrelevant (at least for now). If any character however kills the object, you would like to know that, especially if two characters are hitting the object at more or less the same time. In this case, you can work with the timestamp from the PhotonMessageInfo, which you will automatically get when receiving the RPC: [PunRPC] void DealDamage(int damage, PhotonMessageInfo info).

so i made it to send the attack data
to masterclient and give damage in
masterclient and send this data to all
other clients. then it is synced
exactly, but its delay of sending many
RPC(I dont know the exact reason but
its delaying about 0.5~1 seconds) is a
bit critical to my game.

The reason is, that you are sending a network message from one client across the server to the MasterClient, who ‘forwards’ this event across the server to all other clients. This simply takes some time.

Go through this:
link text

In a simple sense, use OnPhotonSerializeView which lies in IPunObservable. Not only it syncs the health correctly to all the clients but also the clients joining afterward. An alternative to this approach is using RPCTargets.AllBuffered but from my experience and from many, it creates more problems than it solves. One more option is there which is using CustomRoomPorperties. Use whichever suits you.