PUN 2 Disconnect and PlayerTTL

Options
Hi, there is a way to disconnect avoiding setting the player inactive even if the PlayerTTL> 0? Exactly as with LeaveRoom (becomeInactive = false), because in theory Disconnect leaves the room but i don't see any overloads. If i call LeaveRoom(false) and then Disconnect doesn't works. Thanks

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Andrex904,

    Thank you for choosing Photon!

    No.
    Calling Disconnect explicitly or unexpected disconnects while joined to a room with PlayerTTL != 0 will cause the actor to become inactive.
  • Andrex904
    Andrex904
    edited September 2020
    Options
    Thank you for the reply! Since I wanted the player to be removed in case of voluntary disconnection without waiting for the TTL, I used this workaround
    public void Disconnect()
    {
    	SetState(MultiplayerState.Disconnected);	
    	if (PhotonNetwork.InRoom)
    	{
    		PhotonNetwork.LeaveRoom(false);
    		isDisconnecting = true;
    	}
    	else if (PhotonNetwork.IsConnected) PhotonNetwork.Disconnect();
    }
    
    public override void OnConnectedToMaster()
    {
    	if (isDisconnecting)
    	{
    		isDisconnecting = false;
    		if (PhotonNetwork.IsConnected) PhotonNetwork.Disconnect();
    	}	
    }
    

    I don't know if it makes sense but maybe it can help someone