GameObject lifetime on the network

Hi, just a question about photon view ids, how long can an object hold on to an allocated view ID? While reading the documentation I see that it says you should unallocate view IDs if the gameobject gets destroyed but what if the object never gets destroyed and I need that object to enter and leave a bunch of rooms? Is that even possible? The current scenario I have is I manually instantiate a player object and when the player enters a room I need to check if the player object has already allocated view ids if not then I call the PhotonNetwork.AllocateViewID to generate some. Of course I then share the view ids to the other player and the other player instantiates the appropriate game object and assigns the photon ids as well. Then when the match starts in the room everything works fine. Once the match is finished, I DO NOT destroy the player object but instead keep the player object alive. Then I try to join another room and everything is fine until the match starts and I start to send/receive RPCs in which I get illegal viewID=0 errors but I can see in the unity editor that both the player object and the other player object have proper view IDs.... So is it assumed that every time a player object enters a room they need to allocate new view IDs? As soon as the player leaves a room those allocated photon view ids to the player's object are no longer valid?

Answers

  • Since no one is bothering to answer this... to workaround the way they design photon views I had to destroy the gameobject and photon view with it after the player leaves the room otherwise the photonview is invalid when the same gameobject is used in another room. I understand that the photon server thin client has to register the photon ids for a specific room but I just don't understand why new view ids have to be allocated by requiring the gameobject to be destroyed and a new one has to be created... Why can't I just ask for new photon ids to be allocated without destroying the gameobject is beyond me