How to know where the thumbstick is pointed at using User Input Service?


Now before I start, I just want to let you know that there is a solution for this by madattak. I just want to see if there is a better way.

I am currently modifying AxisAngle’s skydiving script and trying to make it mobile compatible. Here is the piece of the code that requires the key codes:

function KeyPressed(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		Key = input.KeyCode
		if Key == Enum.KeyCode.D or Key == Enum.KeyCode.DPadRight then
			TwistConvergence = 1.2
		if Key == Enum.KeyCode.A or Key == Enum.KeyCode.DPadLeft then
			TwistConvergence = -1.2
		if Key == Enum.KeyCode.W or Key == Enum.KeyCode.DPadUp then
			TiltConvergence = 1
		if Key == Enum.KeyCode.S or Key == Enum.KeyCode.Down then
			TiltConvergence = -1	

function KeyUnpressed(input)
	if input.UserInputType == Enum.UserInputType.Keyboard or input.UserInputType == Enum.UserInputType.Touch then
		Key = input.KeyCode
		if Key == Enum.KeyCode.D or Key == Enum.KeyCode.A or Key == Enum.KeyCode.DPadLeft or Enum.KeyCode.DPadRight then
			TwistConvergence = 0
		if Key == Enum.KeyCode.W or Key == Enum.KeyCode.S or Key == Enum.KeyCode.DPadUp or Enum.KeyCode.DPadDown then
			TiltConvergence = 0

What I want to do is to replace those “DPad” things with Thumbstick ones. By the way, the DPad does not work either, for some reason.

Is there a better way than madattak’s? All help is appreciated!


Jeeze they don’t make it easy to find, but there is indeed a better way.

local MasterControl = require(player:WaitForChild(“PlayerScripts”):WaitForChild(“ControlScript”):WaitForChild(“MasterControl”))
local MoveVector = MasterControl:GetMoveVector()
if MoveVector.Magnitude>1 then
MoveVector = MoveVector.unit

Edit: Woops, just spent a while digging this up and then realised @Maelstronomer had posted this solution in that same thread XD


Thank you so much! It is really a lot easier to use!