How to make the camera stop rotating when the player holds the joystick down

56/5000
I wrote my own camera scripting system, but it also caused the camera to rotate when I swiped the joystick on my mobile device. Any good Suggestions to solve this problem

2 Likes

Is the cameratype set to scriptable?

Yes, but the camera rotates when I use the DynamicThumbstick

Could you please share your script?

function HandleMove(actionName,UserInputState,inputObject)
	
	if UserInputState == Enum.UserInputState.Change then
		--if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
			
			CAMERA.X = XLIMIT(CAMERA.X - inputObject.Delta.X * CAMERA.Sensitivity.X)
			CAMERA.Y = YLIMIT(CAMERA.Y - inputObject.Delta.Y * CAMERA.Sensitivity.Y)		
		--end	
	end
end

ContextActionService:BindAction("CameraRotate",HandleMove,false,Enum.UserInputType.MouseMovement,Enum.UserInputType.Touch)

I checked the official default camera script code and solved the problem. Thanks for your reply

function isInDynamicThumbstickArea(input)
	local playerGui = player:FindFirstChildOfClass("PlayerGui")
	local touchGui = playerGui and playerGui:FindFirstChild("TouchGui")
	local touchFrame = touchGui and touchGui:FindFirstChild("TouchControlFrame")
	local thumbstickFrame = touchFrame and touchFrame:FindFirstChild("DynamicThumbstickFrame")

	if not thumbstickFrame then
		return false
	end

	local frameCornerTopLeft = thumbstickFrame.AbsolutePosition
	local frameCornerBottomRight = frameCornerTopLeft + thumbstickFrame.AbsoluteSize
	if input.Position.X >= frameCornerTopLeft.X and input.Position.Y >= frameCornerTopLeft.Y then
		if input.Position.X <= frameCornerBottomRight.X and input.Position.Y <= frameCornerBottomRight.Y then
			return true
		end
	end

	return false
end
3 Likes