RequestOwnership - how to know if request was granted or denied?

Options
I have a sphere controlled by the master, and then when I want to grab it with another player, I call RequestOwnership. The master photonview handles this request in OnOwnershipRequest. In this method, I transfer ownership to the new owner, but only if the object isn't currently being held. In other words, I don't want one player to grab an object from another player who is holding it. My question: How does the requesting PhotonView observable know if the ownership request has been granted or denied? I was thinking I could check OnOwnershipTransfered, but this is getting called on the current master, not the new player who is requesting the object.

Comments

  • NavyaGosika
    edited July 2021
    Options
    I am in need of the same thing. I need a callback for ownership request denied but the interface doesn't provide a method for it. Right now I am using coroutines to wait for 15 seconds and if the transfer doesn't happen assume it's denied, which is not the ideal way to do it but have no option. Is there any way to get a callback?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @NavyaGosika, @BuilderWorldVR,

    Thank you for choosing Photon!


    I think this was added in v2.29 (15. March 2021) according to PUN2's version history page.
    Added: IPunOwnershipCallbacks.OnOwnershipTransferFailed. This helps react when an Ownership Transfer request failed (due to earlier changes). This might mean you have to implement OnOwnershipTransferFailed in some scripts.

    ---

    @BuilderWorldVR,

    (sorry for the delay) sometimes we miss some discussions, I hope you managed to find a solution to your problem. If you don't get help within 2 business days you can send us an email.