Player being destroyed on slight network disconnection

I have set the room options correct with autocleanupcache set to false and PlayerTTL to 5 sec. But even so, the player gameobject just gets destroyed the instant network is lost on mobile build.

In the editor on the other hand, everything works as intended and slight network disconnections doesn't cause the player to get destroyed. Any idea what could be causing this ? This issue has been bugging at me for a few days now.

Answers

  • Just took a PC build and found its working as needed on PC. It waits 5 seconds before destroying the gameobject.

    So its a platform specific issue ? Any idea guys ?
  • bump
  • L3scL3sc
    I have the same issue as you described above. The only thing I'm doing differently, when I realize that the connection has been lost I'm forcing manually PhotonNetwork.Disconnect() for clear and easy reconnect. I started to think that what I did was causing this.

    Instantiate method: PhotonNetwork.Instantiate
    Tested editor and mobile
    Pun v2.27
  • L3scL3sc
    edited May 18
    I figured out this by editing photon code. Inside PhotonHandler:
    public void OnLeftRoom()
      {
                // Destroy spawned objects and reset scene objects
                PhotonNetwork.LocalCleanupAnythingInstantiated(true); // line 303
        }
    

    This is true by default. The parameter is allowing destroy instantiated objects. So I changed parameter to false. I wish it was optional because we can't access PhotonNetwork.LocalCleanupAnythingInstantiated inside our scripts. So I want to ask Photon Pun experts and admins is there any problem to change this line?

    @JohnTube @Tobias

    Edit: Photon throwing error on reconnectandrejoin after the parameter is changed:
    PhotonView ID duplicate found: 2001. New: View 2001 on Player(Clone)  old: View 2001 on Player(Clone) . Maybe one wasn't destroyed on scene load?! Check for 'DontDestroyOnLoad'. Destroying old entry, adding new.
    

    Should I ignore?

    Edit2: The gameobject destroys on rejoin anyway even setting parameter to false or commenting line. The last sentence of the error refers to this.
    How should we do to prevent this from happening except player ttl expired?
Sign In or Register to comment.