Health/Damage system in Photon Cloud

Hello!

I am doing the health/damage system now. I am in doubt… Should I use only RPCs or OnPhotonSerializeView. Maybe I should combine them?

The problem is that if I use only RPCs, the later connected players does not have any information about HP of others. Of course, I can use buffered. However, it should work, theoretically, until the sender quit. How to fix the problem? Could you provide me a solution? I do not need code, but performance of how it should be.

Thank you!

Buffering wouldn’t be that good because new connected player will be bombed with all buffered messages.
OnPhotonSerializeView would be the best way to sync clients health.

1 Like

Yeah, okay. Thank you for the answer!

So, my way of thinking:

  • I press fire, check the hitting and other game logic. Afterwards, send RPC to the victim (with option of PhotonTargets.All).
  • Victim’s realization of the RPC request decreases hp of the player.
  • Somewhere in the bottom I use OnPhotonSerializeView anyway to sync hp if some new players connect to us.

Correct? This is the best way to solve the task?

Yeah, fire,detect,send to target. That’s all ^^

1 Like