Search Unity

Third Party Photon Pun OnTriggerEnter function

Discussion in 'Multiplayer' started by Y_Gunes, Jan 2, 2019.

  1. Y_Gunes

    Y_Gunes

    Joined:
    Apr 1, 2018
    Posts:
    5
    Hello, in my script 2 players side by side i have activated a button , button name is raceButton.Function works when the 2 players come side by side, the test button is active,but the raceButton button is active in all players. I just want to be active in side-by-side players.

    How can I do that.

    This is my code:

    Code (CSharp):
    1. private void OnTriggerEnter(Collider other)
    2.    {
    3.        if (other.gameObject.tag=="Player")
    4.        {
    5.            Debug.Log("Araçlar yanyana");
    6.            target = other.gameObject.transform;
    7.            view.RPC("VeriGonder", PhotonTargets.AllBuffered, sender.gameObject.GetPhotonView().viewID, target.gameObject.GetPhotonView().viewID);
    8.        }
    9.    }
    10.  
    11.    [PunRPC]
    12.    void VeriGonder(int senderView, int targetView)
    13.    {
    14.        sender = PhotonView.Find(senderView).transform;
    15.        target = PhotonView.Find(targetView).transform;
    16.  
    17.        ownerId = sender.gameObject.GetPhotonView().viewID;
    18.        playerNameText = target.GetComponent<PhotonView>().owner.NickName;
    19.  
    20.  
    21.        if(target!=null)
    22.        {
    23.          sender.GetComponent<Gunes>().raceButton.SetActive(true);
    24.          target.GetComponent<Gunes>().raceButton.SetActive(true);
    25.        }
    26.    }
     
  2. alpgul02

    alpgul02

    Joined:
    Jan 17, 2019
    Posts:
    1
    Merhaba Güneş Bey,
    Size bir soru sormak istiyorum. Sorum:
    Unity Photonda multiplayer oyun yapıyorum 2 oyunculu. Yeniyim biraz. Her şey tamam ama oyuncu kontrolüne gelince(bir buton yaptım hareket için) bu buton çalışmıyor. Event trigger kullanıyorum. Tek oyuncu odaya girince çalışırken 2. Oyuncu oyuna girdiğinde hareket butonu çalışmıyor. Lütfen yardım eder misiniz ? Ne yapabilirim ?
     
  3. Y_Gunes

    Y_Gunes

    Joined:
    Apr 1, 2018
    Posts:
    5
    @alpgul02 Merhaba Hocam yazdığın kod içerisinden bir örnek gönderebilir misiniz? yardımcı olmaya çalışayım.Tahmin ediyorum photonview.isMine kullanımı ile ilgili bir hara vardır.