Illegal view ID:0

Options
Hello,
First off I would just to say I'm loving PUN and everything it has to offer! Really simplifies the networking process :)

I'm having a slight issue with instantiating a prefab via an RPC; I keep getting the error "Illegal view ID:0". I understand that the ID needs to be a positive number; however, I though this was something that got set automatically. I didn't have this issue when I was instantiating the prefab via PhotonNetwork.Instantiate. I've been searching around for the past couple of days and haven't been able to find any solution that works for me. Any thoughts? Here's the code stripped down so you can see the important bits:

[code2=csharp]private void fireBullet()
{
// instantiate the bullet for server and all clients
photonView.RPC("InstantiateBullet", PhotonTargets.All, this.barrel.transform.position);
}

[RPC]
private void InstantiateBullet(Vector3 _position)
{
// instantiate the bullet
GameObject go = Instantiate(bullet_prefab, _position, Quaternion.identity) as GameObject;

}[/code2]

Comments

  • Tobias
    Options
    Good to read you like PUN and our services. Really cool!

    The viewID is assigned by PhotonNetwork.Instantiate. If you don't use that, you have to allocate and assign a viewID manually and send it along with the RPC.
    Check AllocateViewID() and the (very) brief chapter in the pdf about manual instantiation.

    Let us know if you could or couldn't make it work.