Help syncing Health

So i am working on FPS game. When i first made it (i followed tutorial on Photon website) it was working well. I had projectile firing and after it hit other player that player died no problem. I decided to add Raycast shooting rather than projectile however i have this huge issue... Health doesn't seem to be syncing and whenever lets say Player1 kills Player2, Player1 leaves the game instead of Player2... here are codes:

	void Fire()
		RaycastHit hit;
		Debug.DrawRay (fpsCam.transform.position, fpsCam.transform.forward,;
		if (Physics.Raycast (fpsCam.transform.position, fpsCam.transform.forward, out hit)) {
			Debug.Log (;
			PlayerManager1 target = hit.transform.GetComponent ();

			if (target != null) {
				target.TakeDamage (damage);
	public void TakeDamage (float amount)
		Health -= amount;
		if (Health <= 0f)
	void Die ()
Please help. I am beginner in Photon and I'm kind of lost because there aren't too much tutorials out there :)


  • Hi,

    Typically, you must not have each client check for damage, only the owner or only the masterClient, else you will run into race conditions and most likely differences in behavior due to the latency of the network, which is something unavoidable.

    I strongly advice you check the basic tutorial which will show you one secure way to check for damage.

    Make sure you go through the whole tutorial if it's not clear, this is a step by step tutorial. Let me know if you have questions after you went through it.


Sign In or Register to comment.