Synchronize Objects without an Owner (Not using OnPhotonSerializeView)

Options
Hello guys!

I am trying to synchronize positions and rotations of objects in my game. I have tried OnPhotonSerializeView and PhotonTransformView but I realised that those only work when you one of the clients take ownership of the object. The owner will be responsible for sending out the updates to other clients.

What I need:
Multiple players updating an object that will be reflected in other clients. Any player can take control of the object and other clients have to update the object's position according to the owner.

Thanks!
Justin

Comments

  • Hi @Justin_ou,

    if I understand you correctly I would recommend you taking a look at the Ownership Transfer guide which will help you achieving the behaviour you want to have.
  • Justin_ou
    Options
    @Christian_Simon Thank you! Somehow I missed this in the documentations. I actually went ahead to implement my own ownership workflow with player ids acting as tokens.

    In addition to that, how would one control ownership if items move due to collisions from another object? For example, if I control a bat that hits Object A, Object A moves in my scene but how should I update this in another scene?
  • For example, if I control a bat that hits Object A, Object A moves in my scene but how should I update this in another scene?


    What exactly do you mean? Do you want to know how you can update the movement on another client as well? Therefore you have to add a PhotonView and a PhotonTransformView component (the PhotonTransformView needs to be observed by the PhotonView component) to the object (prefab).
  • Justin_ou
    Options
    @Christian_Simon Thanks. I understand better after reading the documentations as well.

    May I know whats the performance difference between:

    1) Using OnPhotonSerializeView or PhotonTransformView to update transforms in real time

    2) Sending an RPC call 10 times a second to update positions
  • I honestly don't know about any differences on performance. When using default settings OnPhotonSerializeView is called 20 times per second, means that you have 20 position, rotation and possibly scale updates per second. Based on your game this may result in somehow smoother movement of other clients game objects. You can also adjust this value to send less or even more (not recommended) updates. Also the PhotonTransformView is optimized for those kind of updates and provides for example interpolation options as well.
  • Justin_ou
    Options
    Thank you sir! I'm using RPC calls and it seems good for now. Thanks for your help!