0
votes

Im working on a demo project, where I use Unity 3D and Photon Unity network(PUN) for a real time game.

Here's an image

The person in the top panel is an enemy unit, controlled by another player who does damage to the player on the bottom left (1/3 hp left). However, the person on the bottom right is a healer who can heal the bottom left player (both controlled by the local player).

Here's my problem! Since it isn't turn based and has to happen real time. How do I design my multiplayer system? Ive previously worked on turn based games, where I just pass the indices and mirror the events taking place locally, in the remote player as well.

But here with latency in the picture, I do not know how to proceed! What I would like to do is, have the healer heal the player locally as well on the remote player's phone before he is attacked by the remote player or kill the player before the healer can heal his hp depending on the timestamp in which the events happen and reflect such on both the devices.

1

1 Answers

1
votes

I think you are confused with some of the pun networking features.

If the healer heals your local player, so will be the remote instances of your local player. Your healing system must be networked of course, make sure you go through our basic tutorial to learn how to implement a simple health system.

https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/player-networking#health_synchronization

What will be slightly more complex than health management is the switch between your player and healer locally. for this you have two main variants.

  1. transfer ownership between the player and healer: https://doc.photonengine.com/en-us/pun/v1/demos-and-tutorials/package-demos/ownership-transfer (this is a v1 demo but the principle still applies to v2)

  2. have a invisible network player, and using your own logic in your game, have the player matching this invisible network player or the healer matching it.