PUN2: Proper usage of OnOwnershipTransfered

Hello there,
I was just hoping for some clarification on what is standard practice for dealing with client ownership. From the PUN 1 documentation and video tutorials I have watched, it seems that OnOwnershipRequest is supposed to be called only once in the scene.
However, in PUN 2, this requires implementing the IPunOwnershipCallbacks interface.

OnOwnershipTransfered is another function that needs to be defined by classes that implement IPunOwnershipCallbacks.
Is OnOwnershipTransfered only supposed to be called once in a scene as well?

This is important to know because I have a script called NetworkOwnershipHandler that handles the OnOwnershipRequest, but it is required to define OnOwnershipTransfered. In that class, I leave it blank.

There is another class where I intend to listen for when an ownership transfer has completed, then proceed to call a function that grabs an object. However, to listen for OnOwnershipTransfered, I have to implement IPunOwnershipCallbacks, which means that I have to define OnOwnershipRequest, which I end up leaving blank because it's already defined in my NetworkOwnershipHandler.

This means I have two different classes that each have IPunOwnershipCallbacks functions that are defined as blank. I was wondering if there was a more effective solution to listening for the completion of OwnershipTransfers, because this seems a bit odd, and understanding this would give me insight in how to solve certain bugs.

Thank you very much!!



    it is basically enough to have the IPunOwnershipCallbacks interface implemented just once in the game. However it won't be a big problem if you have it twice or more often in the game. In this case you would have an empty function for each IPunOwnershipCallbacks implementation which gets called additionally. The important aspect is, that you only have the logic once in the game. You would have for example problems, if you have OnOwnershipRequest twice in the game and one of them does another thing than the other one.
Sign In or Register to comment.