Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug [PUN] Illegal view ID error

Discussion in 'Scripting' started by FartGamingLol, Apr 10, 2024.

  1. FartGamingLol

    FartGamingLol

    Joined:
    Mar 8, 2024
    Posts:
    3
    so im trying to make an object spawn across all player views but the object does not enable and the photon view is assigned and i have no clue whats causing this error

    Error message:
    Illegal view ID:0 method: EnableObject GO:player
    UnityEngine.Debug:LogError (object)
    Photon.Pun.PhotonNetwork:RPC (Photon.Pun.PhotonView,string,Photon.Pun.RpcTarget,Photon.Realtime.Player,bool,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1204)
    Photon.Pun.PhotonNetwork:RPC (Photon.Pun.PhotonView,string,Photon.Pun.RpcTarget,bool,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2940)
    Photon.Pun.PhotonView:RPC (string,Photon.Pun.RpcTarget,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:604)
    NetworkedEnable:OnTriggerEnter (UnityEngine.Collider) (at Assets/Scripts/NetworkedEnable.cs:15)


    Warning Message:
    Received RPC "EnableObject" for viewID 0 but this PhotonView does not exist! Was remote PV. Remote called. By: #01 '' Maybe GO was destroyed but RPC not cleaned up.
    UnityEngine.Debug:LogWarning (object)
    Photon.Pun.PhotonNetwork:ExecuteRpc (ExitGames.Client.Photon.Hashtable,Photon.Realtime.Player) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:412)
    Photon.Pun.PhotonNetwork:RPC (Photon.Pun.PhotonView,string,Photon.Pun.RpcTarget,Photon.Realtime.Player,bool,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1267)
    Photon.Pun.PhotonNetwork:RPC (Photon.Pun.PhotonView,string,Photon.Pun.RpcTarget,bool,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2940)
    Photon.Pun.PhotonView:RPC (string,Photon.Pun.RpcTarget,object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonView.cs:604)
    NetworkedEnable:OnTriggerEnter (UnityEngine.Collider) (at Assets/Scripts/NetworkedEnable.cs:15)


    Code:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Photon.Pun;

    public class NetworkedEnable : MonoBehaviourPun
    {
    public GameObject objectToEnable;
    public PhotonView photonView;

    void OnTriggerEnter(Collider other)
    {
    if (!photonView.IsMine && other.CompareTag("HandTag"))
    {
    photonView.RPC("EnableObject", RpcTarget.All);
    }
    }

    [PunRPC]
    public void EnableObject()
    {
    objectToEnable.SetActive(true);
    }
    }

    i dont want to be stuck of this error for days.
     
  2. FartGamingLol

    FartGamingLol

    Joined:
    Mar 8, 2024
    Posts:
    3
    the photon view is assigned by a prefab in my folders btw
     
  3. FartGamingLol

    FartGamingLol

    Joined:
    Mar 8, 2024
    Posts:
    3
    Nvm i rewrote the code to be simpler it works now.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,589