Transfer Ownership photon2

90

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);
	}

Comments

Submit
0 Comments