PUN1 - Is it possible to ReconnectAndRejoin() without reinstantiating room objects?


I am implementing a flow that gives players a 10 second window to reconnect and rejoin a room after they disconnect from my multiplayer game. If the reconnect and rejoin are successful, I would like to maintain the state of all of the objects on the reconnecting player's client and resume play. It is a turn-based game that takes place in a single scene, so I am fairly confident that changes will not have taken place which could compromise the game state.


Upon reconnecting, all of the room's gameobjects are reinstantiated and each one produces the following error:

PhotonView ID duplicate found: 1001. New: View (0)1001 on Agent(Clone)  old: View (0)1001 on Agent(Clone) . Maybe one wasn't destroyed on scene load?! Check for 'DontDestroyOnLoad'. Destroying old entry, adding new.

All of the objects are replaced, which means they lose their connections and context. After reading this thread, I also tried PhotonNetwork.DestroyAll() which solved for the errors, but connections and context are lost in that scenario as well. Manually re-establishing the state of each object would be prohibitively difficult.


Is it possible to stop PUN from reinstantiating these objects on rejoin if they already exist?If this is not possible, do you have any recommendations for how to maintain connections and context(e.g. script/object references, tables of data, variables, etc.) on reinstantiation?

Best Answer