Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Pun ViewId problem

Discussion in 'Multiplayer' started by macdonaghpm, Oct 9, 2022.

  1. macdonaghpm

    macdonaghpm

    Joined:
    Apr 26, 2021
    Posts:
    63
    I have code that should call an RPC:
    Code (CSharp):
    1. pv.RPC("DestroyOverNetwork", RpcTarget.All, hit.collider.transform.GetComponent<PhotonView>().ViewID);
    and code that should check if the id matches:
    Code (CSharp):
    1. [PunRPC]
    2.     void DestroyOverNetwork(int id)
    3.     {
    4.         if (GetComponent<PhotonView>().ViewID == id)
    5.         {
    But for some reason the view id I get in the function from GetComponent<PhotonView>().ViewID does not match what I see in the inspector and get from the raycast hit view id
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,957
  3. macdonaghpm

    macdonaghpm

    Joined:
    Apr 26, 2021
    Posts:
    63