Equivalent to UserInputType.MouseMovement for Mobile?

Hi!
I’m trying to create my own version of shift-lock for my game. So far it works great on desktop and is doing everything I need it to. However, recently I began testing for mobile, and realised the input method I used for detecting when to move the camera only works with a mouse/trackpad, thus making it impossible to move the camera around. I’ve tried searching similar titles but haven’t found anything on it, and I’m unsure what to do.

	UserInput.InputChanged:Connect(function(input, processed)

		if processed then return end

		if input.UserInputType == Enum.UserInputType.MouseMovement then
			self.x -= input.Delta.X
			self.y = math.clamp(self.y - input.Delta.Y*0.4, -75, 75)
		end
		
	end)

It’s very simple here, but I’d like to be able to get a “Delta” from the swipe of fingers across the screen as well, and translate that into something I can use to change self.x and self.y. I would assume something like TouchSwipe but I’m not too familiar with mobile input as a whole, which is probably why I’m having this issue to begin with.

Any suggestions would be massively appreciated!

The .TouchPan() event from UserInputService might be useful.
https://create.roblox.com/docs/reference/engine/classes/UserInputService#TouchPan

1 Like

Thanks for the suggestion! I’ve just figured out the way that works best for me though

I believe it’s similar:

	UserInput.TouchMoved:Connect(function(touch,processed)
		if processed then return end
		
		self.x -= touch.Delta.X
		self.y = math.clamp(self.y - touch.Delta.Y*0.4, -75, 75)
	end)

Using similar code, I’ve found that “TouchMoved” exists which has all the same properties as “MouseMovement”, including the delta which I was looking for!

Thanks again for taking the time to reply though. :slight_smile:

2 Likes

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