Photon View ID

Options
Hello,

I'm using PhotonNetwork.AllocateViewID() to generate unique viewID. But it is returning a value of 0 the first time, and this is generating an error due to a condition checked by photon if the viewID is less than 1.
I was wondering why the viewID shouldn't be 0 while the AllocateViewID() generates a 0? And how can I evade this error?

Thanks!

Comments

  • lello200
    Options
    Just wanted to add that I am adding a PhotonView script dynamically in the code to a singleton gameobject, this is making the view ID assigned at runtime, and it is getting the value of 0. and if I use PhotonNetwork.AllocateViewID() most of the time I get the value of -999 (eventhough I'm in a room)
  • Tobias
    Options
    I assume you're calling AllocateViewID() before you get into a room. This is when your player has a non-valid ID (-1) and we're not catching this in AllocateViewID().

    You could add Debug.Log("AllocateViewID") to AllocateViewID and check the callstack. Also, log your PhotonPlayer.ID. When you got the first callstack, post it here.
  • lello200
    Options
    My bad Tobias, I was calling AllocateViewID() right after calling JoinRoom() and not in the OnJoinedRoom() callback.

    Thank you!