Maintaining parent/child relationships

Options
I'm not a novice programmer, but I am working on my first major foray into networking, and finding it very confusing...

I'm working on a card game, two players watching the same play area from opposite sides.

The first player in becomes Player 1, and spawns all the cards (which have PhotonViews attached). The game looks fine from this player's side.
When a second player comes in and becomes player 2, they can see all the cards, but the locations are only the local positions.

If a card is in a deck or a hand, they are made children of that deck or hand.
But all the cards are showing to player 2 as if they were parented to an object at the origin.

I realize I could set up the functions that assign the parent to reflect this across the network, but what do I do when the parent/child relationship is set up before the second player even joins?

Is there a way to force the PhotonView to send the global position, rather than the local?
Perhaps I should change my code so that the cards aren't actually parented to the various containers?

So many questions! :shock:

Comments

  • vadim
    Options
    You may replicate parenting operations on all clients with RPC (probably with PhotonTargets.OthersBuffered).
    Also you may try OnPhotonSerializeView to sync global positions.
    And may be simplest is not to parent objects at all.
  • Thanks for the help; that's exactly what I ended up doing last night. I wrote an RPC called SyncCard(), put a call to it in the already existing Proc() function I had running periodically on my cards.
    It basically sends the global position out, and if the value does not agree with the current position, they move to the value.
    Makes a good simulation of asynchronous play, because those Proc() updates only happen at certain intervals.
  • Tobias
    Options
    I wonder if you need to sync the position. Are the cards anywhere on a table or so? From what I know, I'd arrange them in slots and spread them, according to how many are on the hand or played on the table or so.
    If you don't use the exact location, you can also send the position as "3rd card on hand" or so. Then you can move the cards when you get a "played".