PhotonView.TransferOwnership C# (CSharp) Method

TransferOwnership() public method

Transfers the ownership of this PhotonView (and GameObject) to another player.
The owner/controller of a PhotonView is also the client which sends position updates of the GameObject.
public TransferOwnership ( PhotonPlayer, newOwner ) : void
newOwner PhotonPlayer,
return void
    public void TransferOwnership(PhotonPlayer newOwner)
    {
        this.TransferOwnership(newOwner.ID);
    }

Same methods

PhotonView::TransferOwnership ( int newOwnerId ) : void

Usage Example

Example #1
0
    /// <summary>
    /// Migrate informations while using RPC Requests #TRY#
    /// </summary>
    private void MigrateInformations()
    {
        //MIGRATE ALL DATAS FOREACH ENEMY AND PROPS
        //Start informations with the id of the previous master
        string _info = $"{ hostingManagerPhotonView.owner.ID }@";

        for (int i = 0; i < allAreas.Count; i++)
        {
            TDS_FightingArea _area = allAreas[i];
            _area.ClearDeadEnemies();
            if (_area.DetectionState == SpawnPointState.Enable)
            {
                // SEPARATE WITH & AND ADD OTHER INFOMATIONS
                if (i >= 1)
                {
                    _info += '&';
                }
                _info += _area.GetFightingAreaInfos();
            }
        }
        //ADD PROPS INFORMATIONS + SEPARATE WITH @

        //SEND INFORMATIONS TO THE NEW MASTER
        TDS_RPCManager.Instance.RPCManagerPhotonView.RPC("ReceiveMigrationsInformations", PhotonTargets.MasterClient, _info);
        hostingManagerPhotonView.TransferOwnership(PhotonNetwork.masterClient);
    }
All Usage Examples Of PhotonView::TransferOwnership