Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Transfer Ownership photon2

//With the PhotonView set as "Takeover"
// From the object that is asking for the ownership:

public void requestOwnershipExample() {
	base.photonView.RequestOwnership();
}

//With the PhotonView set as "Request"

public class OwnershipTranserExample : MonoBehaviourPun, IPunOwnershipCallbacks // NEEDED
{
	Private void Awake()
	{PhotonNetwork.AddCallbackTarget(this);}

	Private void OnDestroy()
	{PhotonNetwork.RemoveCallbackTarget(this);}

	public void OnOwnershipRequest(PhotonView targetView, Player RequestingPlayer)
	{
		if (targetView != base.photonView)
		return;

	 	//Add checks here

	 	base.photonView.TransferOwnership(requestingPlayer);
	}
Source by # #
 
PREVIOUS NEXT
Tagged: #Transfer #Ownership
ADD COMMENT
Topic
Name
9+4 =