TouchPan firing briefly after TouchRotate/TouchPinch end

I’ve tried several methods in an attempt to nullify this issue but to my dismay it seems as if I cannot find a reliable method.

TouchPan (after TouchRotate and TouchPinch end) is fired for less than a tenth of second (sometimes only lasting a hundredth to a thousandth of a second starting from the first change state to end state).

This doesn’t occur 100% of the time either, it happens randomly.

Has anyone else had this issue and if so what did you do to solve it?

(This could also be a Roblox bug and if so I’ll report it.)

I have seen this issue. I have chosen to leave it be in my particular case, as it only occurs in a mode where it controls the camera and the camera automatically pans back to the center in that particular mode anyway.

I’d advise making a variable that holds a tick value for when pinch/rotate ended. If the pan started less than 1/5th (or similar) second since that tick, ignore it.

The problem you have is that if someone pinches, then removes 1 finger, you need to decide whether then keeping on the second finger and panning with it should count as a pan or not. If so, then you can’t ignore it. If you don’t mind that edge case resulting in an ignored pan, then do what I suggested above.

I’ve found a solution that works so far, however; although I would really love this to be a bug it is simply a remaining finger being lifted for an unspecific amount of time and most likely would be fairly impossible to eliminate.

The idea is to simply monitor the amount of changes made in the pan that occurs directly after rotation/pinching, once you have that number assume it remains that way. The number I’ve come to be accurate is 3 changes. Wait until those changes are over, and then add in an additional measure.

Code:

-- Services
local Input = game:GetService("UserInputService")

-- Variables
local rotateZoomFlag, pantStarted

-- Events
Input.TouchRotate:Connect(function(_, _, _, state) -- Could check finger count to determine state
    if state == Enum.UserInputState.Change then
        rotateZoomFlag = 0
    end
end)

Input.TouchPinch:Connect(function(_, _, _, state)
    if state == Enum.UserInputState.Change then
        rotateZoomFlag = 0
    end
end)

Input.TouchPan:Connect(function(_, _, _, state)
    if state == Enum.UserInputState.Change then
        if rotateZoomFlag and rotateZoomFlag < 3 then
            rotateZoomFlag = rotateZoomFlag + 1
        
            return
        elseif not panStarted then
            panStarted = true

            return
        end

        -- Code
    elseif state == Enum.UserInputState.End then
        panStarted = false
    end
end)

If anybody has a proper solution then please reply with it as this is a solution that to my knowledge has not led to an ignored pan and does not sacrifice being able to pan using the same finger used in Rotation/Pinch.