Search Unity

Third Party Photon, access to a specific player's variable

Discussion in 'Multiplayer' started by Y_Gunes, Dec 28, 2018.

  1. Y_Gunes

    Y_Gunes

    Joined:
    Apr 1, 2018
    Posts:
    5
    Hi friends, I am developing a game using photonnetwork,

    I want to do this, I want to write a text ("Target accepted") to a specific player's text variable using RPC.

    I've written a code as follows, but it doesn't write anything in the text variable.Interestingly The unity editor debug console also writes "Target accepted".


    Do you think what is wrong, or is there a method you can suggest?

    Code (CSharp):
    1.  public void OwnerKabul()
    2.     {
    3.        view.RPC("TargetAcceptRpc", PhotonTargets.AllViaServer, sender.gameObject.GetPhotonView().viewID, target.gameObject.GetPhotonView().viewID);
    4.     }
    5.  
    6.     [PunRPC]
    7.     void TargetAcceptRpc(int senderView, int targetView)
    8.     {
    9.         sender = PhotonView.Find(senderView).transform;
    10.         target = PhotonView.Find(targetView).transform;
    11.      
    12.         sender.GetComponent<Gunes>().isOwner = true;
    13.         target.GetComponent<Gunes>().isOwner = true;
    14.    
    15.        if(view.isMine)
    16.         {
    17.             targetUserName.text = target.GetComponent<PhotonView>().owner.NickName;
    18.         }
    19.         else
    20.         {
    21.             targetUserName.text = sender.GetComponent<PhotonView>().owner.NickName;
    22.         }
    23.  
    24.         target.GetComponent<Gunes>().targetAcceptText.text = "Target accepted";
    25.  
    26.         Debug.Log("Look here " + target.GetComponent<Gunes>().targetAcceptText.text);
    27.  
    28.         //canvas.gameObject.SetActive(false);
    29.     }
     
    Last edited: Jan 10, 2019