I want to add mobile support to my game, aside from the UI, the only thing that needs to work is getting the mouse.hit for a mobile tap. I have seen this:
function TouchEnded(touch, gameProcessedEvent)
print("Touch ended at "..tostring(touch.Position))
end
UserInputService.TouchEnded:Connect(TouchEnded)
Which seems like it should work, but I dont know if touch.Position is a vector2 or a vector3 similar to mouse.hit (yea I know I should not use :getmouse(), it’s just too convenient: previous post on mouse.hit)
Here is the full code
local function firerer(pos)
if delaying==false and (DefWin.Value==false or DefWin.Value==false) then
delaying=true
--...
local MousePosition=nil
if not pos then
MousePosition=pos
else
MousePosition=mouse.Hit
end
--...
end
end
UIS.InputEnded:Connect(function(hit)
if hit.UserInputType==Enum.UserInputType.MouseButton1 then
firerer()
end
end)
if UIS.TouchEnabled then
UIS.TouchEnded:Connect(function(touch)
local pos=touch.Position
firerer(pos)
end)
end