Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

Syncing AI enemy health

$
0
0
Hi
I just started using photon and after watching lof of tutorials, i am trying to sync Enemy AI health.
My player is a mele player and when i hit enemy i am trying to sync damage to AI.

[PunRPC]
public override void TakeDamage(Damage damage)
{ PhotonView pv = this.GetComponentInParent<PhotonView>();

pv.RPC ("reducehealth", PhotonTargets.Others, damage.value);
}
[PunRPC]
public void reducehealth(int dmg)
{
currentHealth -= dmg;
currentHealthRecoveryDelay = healthRecoveryDelay;
}
Now the problem is when i hit enemy, sometimes damage is sync while sometimes it doesnt get sync. This results in enemy health being different in both clients.
So why does this happens, does rpc sync calls get lost??
Is here a possible solution for this.

Thanks

Viewing all articles
Browse latest Browse all 8947

Trending Articles