How to syncronize values without be owner

Hello friends,

My name is David, i need some info about synchronize values without be owner

I'm developing a game where there are islands with gold. These can be attacked by players
When a player attack an island, the island's gold reduce.

This is the idea, my problem is:
I am using OnPhotonSerializeView to share the values, but only the owner can send them...
Currently, when a player attack an island, he request be the new owner.
After that, he can reduce the island's gold and share the new gold value.

What happen if more than one player attack the island?
Here is the real problem, be the new owner takes 0.5 or 1s.

Other option is use RPC to notify the owner to reduce the gold
I need a way to update the gold fast, without owner requests, any ideas?

Thanks guys,

David

Answers

  • have the masterclient keep track of who hit the island, and how much gold was in the island when hit. Have the master client process this information, deliver the gold to the respective client, and when there is no more gold, the masterclient can remove the island. I hope this makes sense.
  • sdsdink wrote: »
    have the masterclient keep track of who hit the island, and how much gold was in the island when hit. Have the master client process this information, deliver the gold to the respective client, and when there is no more gold, the masterclient can remove the island. I hope this makes sense.

    Thanks friend, I get it
    The players can notify through RPCs and the master update and notify through onPhotonSerializeView

    But I have another question, what happens if the master leave the game? how can i control this easily?
  • I'm new to Photon, but it seems like maybe the best way to approach your problem might be to have a Room Property for each island that keeps track of its gold quantity, and have players update the property each time they attack it. Here's a tutorial video I found on another forum post that explains the gist of creating and updating room properties:

    https://www.youtube.com/watch?v=aVUNiJ3MVSg

    And to make sure you employ check-and-swap if it's possible you'll have players attacking an island concurrently:

    https://forum.photonengine.com/discussion/comment/32581/#Comment_32581

    (the commenter says they think their code is wrong but you can see right after a member of the Photon team says it's correct)

    This seems like a better design choice than to have the MasterClient be the arbiter of all players' actions. I would think that would get messy fast.