UserInputService Touch event doubt

I have a doubt about UIS.TouchPan. While using the code provided in the documentation, the “velocity” print is always 0, 0. Thats normal? docu says Velocity is “The speed of the pan gesture (in pixels) per second”. But no matter how fast I move my finger on the screen its always 0,0

local userInputService = game:GetService("UserInputService")

userInputService.TouchPan:Connect(function(touchPositions, totalTranslation, velocity, state, gameProcessedEvent)
	print("Speed of touch drag: "..tostring(velocity))
end)

My second question:
I want to use UIS.TouchPan But, it seems not recognizing inputs in studio, only when using a real touchDevice, am I right?

2 Likes

The code you provided works perfectly on a real mobile device; tablet and or phone (which you have stated at the bottom of your post)

In addition, the studio emulator isn’t really the best when it comes to emulating outside devices. For example, emulating from computer to mobile, and or computer to console. The input types are completely different. You’re better off testing it on a real mobile device.

If you want, you could probably file a bug report for this because I suppose it’s a bug. Mild, but nonetheless, a bug.

2 Likes

Thank you so much for your reply!
Yes Im doing the tests on a touchDevice and checking prints. Right now the fact that I always get the velocity parameter on 0,0 when using a touchingDevice, makes me think its on my end maybe, probably my phone is glitching or something…

Not really important cause I had enough params to accomplish my goal, velocity was not really important.
Thank you for clarifying, yes, emulating a touchDevice on Studio is not reliable yet, I cant even imagine how to handle “pinch” unless using a real touchDevice… which turns testing a little more complicated, but, acceptable. Thank you

2 Likes

I find it hard to believe that it’s a problem with your physical device.

Though you did mention it returned a Vector2: {0, 0}. Which actually makes the “problem with the physical device” pretty viable.

When I tested it on computer via each of the mobile devices, these were the results (unsurprisingly)

Mobile devices (of phones):

  • iPhoneXR - It didn’t return anything. (I’ll refer to it as null)
  • iPhone7+ - null
  • iPhone7 - null
  • iPhone6 - null
  • iPhone4S - null

Tablets:

  • iPad2 - null
  • iPad (6th generation) - null
  • iPad Pro (3rd generation) - null
  • Samsung Tab A (2019, 10.1) - null

I would continue but I’ve lost hope for all the emulated choices. They all follow the same “touch pattern” anyway.

Moral of the story is that the emulator is lacking in quality and in need of proper dynamics.

Still though, not losing sight of my original confusion about your device being “problematic” or “glitchy”. Has the device been damaged in some way?

2 Likes

Thank you for providing that information and for investing your time in testing. It’s helpful to know that the lack of functionality is consistent across all emulated devices.

Honestly, I’m not entirely sure about the issue with my device. It hasn’t sustained any physical damage. However, since the internal memory has become almost full (im not sure if thats the reason…), occasionally, when I unlock the phone to use it, the touch display fails to recognize any movement. After a few seconds, it returns to normal. Once it’s in its normal state, I don’t notice any significant issues while using it… but, there is a chance that I may not be noticing a minor issue or something that’s not easily perceptible to eye

1 Like

This is a known bug for android devices and will be patched in December.

1 Like

That last answer from the Staff on the second post its a relief, so xmas fix in december related with the velocity bug, awesome!
Thank you for providing those posts!
Seems that I was unable to find those posts while researching for this bug… :roll_eyes:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.