Network objects destroyed when having a quick disconnection

Hello !

I came across a problem when starting to handle quick disconnections in my application.

Here's my situation : I have 1 master and 2 clients (clientA and clientB) which all have their own character prefab instantiated on the network. I have set a playerTTL to 60000 in my room options. I frequently have some quick disconnections because of Client Timeout issues (mainly caused by Reliable events not received I guess). Those quick disconnections trigger the OnLeftRoom and OnDisconnected PUN callbacks, but most important, all network objects are destroyed locally (in the client's application).

Here's my issue : Having all the network objects destroyed and then re-instantiated only because of a quick disconnection leads to undesirable behaviour.

What I've done : I only simulated disconnections by calling PhotonNetwork.Disconnect() through an input. I will try to use the Photon Lag Simulation Gui tool later.

Is there any settings that I'm missing that could keep the network objects alive, or is it an
unchangeable PUN behaviour ?

Thanks !


Comments

  • EDIT : I have set the RoomOptions.CleanupCacheOnLeave field to false. Network prefabs are not anymore erased when disconnecting, however the same prefabs are re-instantiated through the LoadBalancingClient.OnEvent() method after rejoining the room, leading to photonView duplicate errors as the previous ones still exist.

    I forgot to mention that I instantly call PhotonNetwork.ReconnectAndRejoin() in the OnDisconnected PUN callback.
  • I am experiencing the same thing. Players who suddenly disconnect are destroyed even with TTL set, in an older version of my game this all works fine. I recently upgraded from Pun 2.12 to 2.16
  • Hello @TijsVdV , as I mentioned, I have set the RoomOptions.CleanupCacheOnLeave boolean to false and now Players are not destroyed anymore when disconnecting. Have you tried using these settings ?
  • No not yet, but you mention in your solution that you are then getting duplicates. This is not want i want.
  • I just realised that my issue is different, the person who disconnects his objects are destroyed this is normal. But it is on the master that his player object is also destroyed even when there is a TTL, this was not like this in previous versions.
  • I managed to "resolve" the issue by editing the PhotonNetwork.cs script.
    In the function NetworkInstantiate(InstantiateParameters, bool, bool), at the very beginning, I added the following snippet :

    if(parameters.viewIDs != null)
    {
    	for (int i = 0; i < parameters.viewIDs.Length; i++)
    	{
    		if(photonViewList.ContainsKey(parameters.viewIDs[i]))
    		{
    			return null;
    		}
    	}
    }
    

    It makes sure that, when quickly rejoining a room that has RoomOptions.CleanupCacheOnLeave set to false, any intern NetworkInstantiate does not perform an instantiation if the corresponding viewID already exists in the scene (i.e was not destroyed when disconnected).