OnOwnershipRequest is being called on all objects

I'll try to explain the problem. I have a prefab which contains a script and a photon view. This prefab is instantiated with PhotonNetwork.Instantiate, let's say, twice. I've checked and they both have different viewIDs. The problem comes when a player executes photonView.RequestOwnership() (this is inside the prefab's script). This objects receives the OnOwnershipRequest() callback, AND the other object (with different photonview id) too! Why?

Comments

  • I forgot to mention that I tried to manually check if the photonviewID matches inside OnOwnershipRequest(). The first time it prints that it is being executed inside the script of photonviewID 1005, and 1005 is the photonviewID being requested (then execute TransferOwnership()). Ok. The second time (which I think, it should not being executed) it prints that it is being executed inside the script of photonviewID 1006, and 1005 is the photonviewId being requested (then don't execute TransferOwnership). However, it does not matters, I end up with two callbacks to OnOwnershipTransfered, both objects have being transfered! ...?
  • Did you ever figure this out?! I have the exact same problem and set of questions. Can't find any answers online. Surely everyone is running into this problem!
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited November 2019
    Hi @develec, @Grant,

    That's how that callback is built by design: they are triggered for all PhotonViews on all classes that implement the callbacks interface.
    However, the actual ownership transfer happens only for the requested PhotonView.

    You can add a check inside the ownership callbacks to dismiss calls for other PhotonViews.
    or you could implement the interface only once, in a class that manages all transfers.