Search Unity

Third Party problem with photon

Discussion in 'Multiplayer' started by AsafMax, May 24, 2015.

  1. AsafMax

    AsafMax

    Joined:
    May 8, 2015
    Posts:
    2
    i want to use RPC for calling function in remote player, my problem is that this function call also in my game and also the remote player, what i missing ?

    this the code

    void Start () {
    GetComponent<PhotonView> ().RPC(
    "PrintSomething",
    PhotonTargets.Others,
    null
    );
    }

    [RPC]
    void PrintSomething()
    {
    // UnityEditor.EditorUtility.DisplayDialog("Big", "you win the game !!", "Ok");
    Debug.Log ("111");
    }

    the code is attach to prefab that have PhotonView
     
  2. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Is PrintSomething() in the same script as start()? I needs to be in the same script.
     
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    To elaborate on this: It has to be in the same script because GetComponent<PhotonView> ().RPC(...) will get the PhotonView of this Game Object and "target" the RPC to this PhotonView / GameObject.
    So actually, PrintSomething can be in another script, but has to be on the same (target) PhotonView / Game Object.