Quantcast
Channel: Recent Discussions — Photon Engine
Viewing all articles
Browse latest Browse all 15755

Photon Instantiating previously loaded objects when I use ReJoinRoom

$
0
0
I am trying to rejoin a room (to support the case of the network connection getting cut when when going to the home screen on an iPhone)

I am creating my room like this:
PhotonNetwork.UsePrefabCache= true;

var room_options = new RoomOptions();
room_options.PlayerTtl = 5 * 1000;
room_options.EmptyRoomTtl = 5 * 1000;
room_options.CleanupCacheOnLeave = false;
room_options.PublishUserId = true;
room_options.MaxPlayers = 8;

PhotonNetwork.JoinOrCreateRoom(room_name,room_options,new TypedLobby("SQL_LOBBY",LobbyType.SqlLobby));

When I use ReJoinRoom after a disconnection it seems all of my PhotonNetwork instantiated objects ( which are still loaded into memory due to room_options.CleanupCacheOnLeave = false ) are trying to be instantiated again and produces many PhotonView ID duplicate found errors. Here is the stack:

PhotonView ID duplicate found: 2. New: View (0)2 on obj_hdqr_0_0_00_00(Clone) (scene) old: View (0)2 on obj_hdqr_0_0_00_00(Clone) (scene). Maybe one wasn't destroyed on scene load?! Check for 'DontDestroyOnLoad'. Destroying old entry, adding new.
UnityEngine.Debug:LogError(Object)
NetworkingPeer:RegisterPhotonView(PhotonView) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3410)
PhotonView:Awake() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:269)
UnityEngine.Object:Instantiate(GameObject, Vector3, Quaternion)
NetworkingPeer:DoInstantiate(Hashtable, PhotonPlayer, GameObject) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3088)
NetworkingPeer:OnEvent(EventData) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2409)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)

I am using PUN v1.80.

Am I missing a room setting or something to get this behaviour working correctly? I notice the exceptions are not created if CleanupCacheOnLeave = true but in the event of a short network disruption when the scene is still loaded and set up correctly in memory I would like to used the cached objects and views as is.

Thank you

Viewing all articles
Browse latest Browse all 15755

Trending Articles