What's the best way to sync objects transform?

Options
My setup: PUN Classic + Photon Server Plugin 4

Here's what I'm trying to achieve.
During the gameplay, plugin creates object for each players then BroadcastEvent to all clients to send object's data. Once clients receive the event, they instantiate gameobjects that can be controlled by owner.

Firstly, I thought about using PhotonNetowrk.Instantiate(), but this will make gameobject get destroyed when the player leaves the room.

Then I considered PhotonNetowrk.InstantiateSceneObject() then pass the ownerships to each players, but the problem is this will also have problem if masterclient fails to create the object. I also really don't want to make anything rely on masterclient (which is just a player).

FInally, I'm wondering if it's better to instantiate everything locally. Every player creates objects for everyone, but it that case I'm not sure how I can sync object's position or rotation. OnPhotonSerializeView or RPCs won't be option since they are created locally, and I'm afraid calling RaiseEvent() everytime there is a small change in position might overwhelm network traffic.

What should I Do?

Comments

  • chvetsov
    Options
    @JohnTube could you recommend anything?

    best,
    ilya
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2020
    Options
    Hi @hanjung,

    The best way is to rely on RaiseEvent (custom events) which are originated from the plugin.

    You could fake instantiation events by rewriting some of PUN's code in the plugin. See here.
    However, PUN was built w/o considering the use case of a custom logic on a server/plugin in place, so it always relies on clients especially for PUN specific features like PhotonView/NetworkedObject/RPC. Meaning even if you start or do the instantiation of scene objects from the plugin, PUN will always attribute ownership to a client. PUN still does not have a server exclusive controlled networked objects. You may still fake that or change PUN code a bit to suit your needs. Or you may implement this yourself.
    Also I cannot suggest having a fake "real" master client that lives only inside the plugin since this is also not 100% supported.