/// <summary> /// Transfers the ownership of this PhotonView (and GameObject) to another player. /// </summary> /// <remarks> /// The owner/controller of a PhotonView is also the client which sends position updates of the GameObject. /// </remarks> public void TransferOwnership(int newOwnerId) { if (OwnershipTransfer == OwnershipOption.Takeover || (OwnershipTransfer == OwnershipOption.Request && amController)) { PhotonNetwork.TransferOwnership(this.ViewID, newOwnerId); } else { if (PhotonNetwork.LogLevel >= PunLogLevel.Informational) { if (OwnershipTransfer == OwnershipOption.Fixed) Debug.LogWarning("Attempting to TransferOwnership of GameObject '" + name + "' viewId: " + ViewID + " without the authority to do so. TransferOwnership is not allowed if PhotonView.OwnershipTransfer is set to Fixed."); else if (OwnershipTransfer == OwnershipOption.Request) Debug.LogWarning("Attempting to TransferOwnership of GameObject '" + name + "' viewId: " + ViewID + " without the authority to do so. PhotonView.OwnershipTransfer is set to Request, so only the controller of this object can TransferOwnership."); } } }
/// <summary> /// Transfers the ownership of this PhotonView (and GameObject) to another player. /// </summary> /// <remarks> /// The owner/controller of a PhotonView is also the client which sends position updates of the GameObject. /// </remarks> public void TransferOwnership(int newOwnerId) { PhotonNetwork.TransferOwnership(this.ViewID, newOwnerId); this.ownerId = newOwnerId; // immediately switch ownership locally, to avoid more updates sent from this client. }