Hi guys.
I want to mke good UI controls, but I’m struggling with some thing regarding them. One of them is multitouch possiblity.
Let’s assume that I have this layout:
Just joystick and jump button.
User begins touch at the joystick:
And moves his finger here:
Then, user touches jump button:
And moves finger here.
But the issue is that it still will fire UserInputService.TouchMoved connection, for each finger, and joystick in my simple implementation will count any movement of any finger.
Here’s how I did it right now:
local function JoystickBegin()
self.Connections.JoystickMove = UserInputService.TouchMoved:Connect(function(Touch, GameProcessed)
local Offset = Vector2.new(Touch.Position.X, Touch.Position.Y--[[+GuiService.TopbarInset.Height]])-GuiSections.Joystick.AbsolutePosition
local CursorPos = Offset/GuiSections.Joystick.AbsoluteSize-Vector2.new(0.5, 0.5)
local JoystickPos = CursorPos.Unit * math.min(0.5, CursorPos.Magnitude)+Vector2.new(0.5, 0.5)
GuiSections.Joystick.Cursor.Position = UDim2.fromScale(JoystickPos.X, JoystickPos.Y)
self.MoveVector = Vector3.new(CursorPos.X*2, 0, CursorPos.Y*2)
end)
self.Connections.JoystickRelease = UserInputService.TouchEnded:Connect(function(Touch, GameProcessed)
GuiSections.Joystick.Cursor.Position = UDim2.fromScale(0.5, 0.5)
self.MoveVector = Vector3.zero
self.Connections.JoystickRelease:Disconnect()
self.Connections.JoystickRelease = nil
self.Connections.JoystickMove:Disconnect()
self.Connections.JoystickMove = nil
end)
end
local Zones = CollectionService:GetTagged("TouchJoystickZone")
self.Connections.JoystickStart = {}
for _, Zone in Zones do
self.Connections.JoystickStart[Zone] = Zone.MouseButton1Down:Connect(JoystickBegin)
end
self.Connections.JumpButtonPress = GuiSections.Jump.MouseButton1Down:Connect(function()
self.IsJumping = self.JumpEnabled and true
end)
self.Connections.JumpButtonEnter = GuiSections.Jump.MouseEnter:Connect(function()
self.IsJumping = self.JumpEnabled and true
end)
self.Connections.JumpButtonRelease = GuiSections.Jump.MouseButton1Up:Connect(function()
self.IsJumping = false
end)
self.Connections.JumpButtonLeave = GuiSections.Jump.MouseLeave:Connect(function()
self.IsJumping = false
end)
So, problem should be visible here.
What I need to do to “fix” this issue?




