Best way to sync object that is being moved by multiple players - please help

Options
Hello,

This is my first time using PUN, so please forgive me if this is a dumb question.

I'm create a "Ouija Board" type game, where multiple players hover over an object to move it around a board, via Rigibody.addforce. I want up to 5 players to be able to be influencing the position and rotation of the object at the same time.

The way I'm handling this right now is pretty terrible, I'm sure. I'm switching ownership of the object every frame in order to give each player equal control over the object.

Each time a player has their cursor over the object, they request control via photonView.RequestOwnership(), and if the player owns the object, it turns off the script that reads the object position for that player. (For this I'm just using the "Interpolate" script from the Sync demo). When the player loses control (isMine = false), it turns the interpolate script back on.

It technically works, the players each are influencing the object by adding force to it, but it looks awful. It jitters around and shifts positions constantly, especially when ownership changes hands.

So I'm doing it dumb way. What is the smart way to handle this scenario?

Thanks a ton for your help. I'm not an experienced programmer, so if you can, please explain everything like you would to a child.

Sincerely,
Jonathan







Answers

  • Chuggsy
    Options
    Please let me know if there's anything I can do to clarify my question; I could really use the help. Thank you.
  • vadim
    Options
    Instead of taking ownership, send RPC to owner of this object with force parameters. The owner will sum up forces and apply result properly.
    Such shared objects are usually "scene objects", created with PhotonNetwork.InstantiateSceneObject call on master client and owned my master.