My code is not working, plis someone help :(

RPC method 'DestroyRpc()' found 2x on object with PhotonView 1002. Only one component should implement it.Return type must be void or IEnumerator (if you enable RunRpcCoroutines).


namespace SetTagPlayer

{

    public class SetTagPlayer : MonoBehaviourPunCallbacks

    {

        private PhotonView photonView;

        void Awake ()

        {  

            photonView = GetComponent<PhotonView>();

           

            if(!photonView.IsMine){

                photonView.TransferOwnership(PhotonNetwork.LocalPlayer);

            }

                photonView.RPC("DestroyRpc", RpcTarget.AllBuffered);

        }

        [PunRPC]

        public IEnumerator DestroyRpc()

        {

            PhotonNetwork.Destroy(gameObject);

            yield return 0;

        }

    }

}

Answers

  • basically I should take the connected object and destroy it, regardless of whether it is the owner or not, for that I used TransferOwnership in case IsMine is false but it doesn't work