I don’t believe there are any KeyCodes or UserInputTypes that refer to the dynamic/virtual joystick for mobile devices. However if you take a look at the DynamicThumbstick module in the new PlayerModule hierarchy, you can figure out how they handle the movement with it (you can also disable it through this module, it seems)
You can utilize ContextActionService to Bind and Unbind Enum.UserInputType.Touch and return Enum.ContextActionResult.Sink if it does not meet your requirements, which should stop it from going through to interfering with your system.
I haven’t put any of this to the test, just throwing some ideas at you to work off of.
it would still interfere and i want to be able to pan the camera up and down , another way i thought of doing this is detecting if the the touch input is happening form the right side of the Screen as thats what most mobile games which uses 3rd Person camera do and i could use the dynamic thumbstick since it only detects control inputs form the left. how do i do this?
(the optimal way) keep the default camera system but restrict movement on the x and y axis by setting it to the desired position every frame.
(the kind of hacky way) detect your touch input on the right side of the screen by getting the position of the touch through InputChanged (as you had originally):
UserInputService.InputChanged:Connect(function(input_object)
if input_object.UserInputType == Enum.UserInputType.Touch then
if input_object.Position.X >= screen_size.X/2 then -- it's on the right side of the screen.
-- do your logic
end
end
end)
You’d get screen size by checking the AbsoluteSize on a ScreenGui or workspace.CurrentCamera.ViewportSize
Another thing you can do is track when the player is using the touch movement inputs. This is pretty much the equivalent of tracking if you’re dragging a GUI element or not (except without the dragging).
Here’s some example code:
local playerModule = require(game.Players.LocalPlayer.PlayerScripts.PlayerModule);
local control = playerModule:GetControls();
-- dragger objects have a property called isDragging and a method onDrag to define the behaviour of the drag
local dragger = require(script:WaitForChild("dragger"));
function dragger:onDrag(guiElement, input, delta)
-- do nothing...
end
-- apply it to track touch control input
local draggedItems = {};
if (control.touchGui) then
for _, child in next, control.touchControlFrame:GetChildren() do
draggedItems[#draggedItems+1] = dragger.new(child);
end
control.touchControlFrame.ChildAdded:Connect(function(child)
draggedItems[#draggedItems+1] = dragger.new(child);
end)
end
local function isInteracting()
for i = 1, #draggedItems do
if (draggedItems[i].isDragging) then
return true;
end
end
return false;
end
game:GetService("RunService").RenderStepped:Connect(function(dt)
print(isInteracting());
end)
thanks , this helped me out a lot i am not sure if i should mark your post as the solution since I’ve already marked @Fm_Trick s post as solution but ill mark it any way
For the dynamic thumbstick, if you copy paste the default playermodule scripts and place in starter player scripts, you can make modifications. I messed around with the DynamicThumbstick module inside of PlayerModule->ControlModule->DynamicThumbstick and found the culprit on line 308
self.moveTouchStartPosition = inputObject.Position
self.moveTouchFirstChanged = true
if FADE_IN_OUT_BACKGROUND then
self:DoFadeInBackground()
end
return Enum.ContextActionResult.Pass --line 308
end
local function inputChanged(inputObject: InputObject)
This function handles touch inputs inside of the thumbstick but for some reason doesn’t sink the input once it’s done. Change line 308 to Enum.ContextActionResult.Sink (don’t change the other ones it will break the inputs).
Now in your own custom camera, wherever you have the UserInputService inputbegan/touchstarted callback:
UIS.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if gameProcessedEvent then return end
end)
The callback is provided a boolean var called gameProcessedEvent, which will be true if the input had been sank (by making the modification I wrote earlier), then you just have your camera script ignore inputs by returning if it detects that bool (OP already has their callback set up to do this)