How do you detect if a player is using the thumbstick on mobile?

Why this is an issue
So the recent Roblox mobile update completely broke the combat system for my game (Empire Clash) for mobile players because it now creates camera movement in the Y direction while the player uses the thumbpad to move. It did not do this until the update this week.

My Solution
To fix this, I need to find a way to detect if a player is using their thumbstick to move or not. This way I can edit my game’s camera scripts so the camera is only effected by touch input that doesnt involve the thumbstick.

What I tried so far
I tried to detect the input using ContextActionService but I got no results. None of the print statements worked.

local function thumbstickDetect(actionName, inputState, inputObject)
		print("H")
		if inputState == Enum.UserInputState.Begin then
			print("Mobile thumbstick usage started")
		elseif inputState == Enum.UserInputState.End then
			print("Mobile thumbstick usage ended")
		end
	end

ContextActionService:BindAction("ThumbstickUsed",thumbstickDetect,false,Enum.KeyCode.Thumbstick1)

If you have any solutions to this, it would be extremely helpful!

3 Likes

This is the closest you can get automatically, although I recommend making a pop-up asking for the movement mode until Roblox fixes the issue, as it is indeed a bug.

I tried this but it doesn’t work. I keep getting this error. For some reason DevTouchCameraMovementMode is not a property we can change in the player like it is shown in the documentation.

I actually meant to link this property. Try it out.
https://create.roblox.com/docs/reference/engine/classes/Player#DevTouchMovementMode

I tried that as well. I also tried directly changing the properties in StarterPlayer. Nothing seems to work.

image

Also this doesn’t really accomplish the original goal of my post anyways, which is to detect of a player is pressing down on their thumbstick or not. If I can do this I can just disable camera movement while the player is using the thumbstick to move and it will be an easy fix.

Not really, you can detect if the user is touching the screen.

Update: We ended up fixing the issue. The cause was a fast flag recently enabled called FFlagUserDynamicThumbstickMoveOverButtons, used in PlayerModule.DynamicThumbstick.

With this fast flag enabled, the thumbstick movement function in DynamicThumbstick returned ContextActionResult.Pass instead of sinking the input, allowing the input to then go through our camera scripts and turn the camera when it shouldn’t. To fix, I forked PlayerModule and disabled the fast flag:

1 Like

Thanks for posting about this, apologies the flag caused issues for your game!
I turned off FFlagUserDynamicThumbstickMoveOverButtons in case this is happening in other games.

This code is listening to gamepad left thumbstick events (on things like Xbox controllers), which is different than the “Dynamic Thumbstick” touch UI on mobile devices.

If you would like to detect if the user is using the Dynamic Thumbstick to move, I think you would need to modify the default PlayerScripts (DynamicThumbstick.lua).

3 Likes

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