Detect how fast a player is moving with the dynamic d-pad

I am trying to develop a system where if the player drags the dpad out a little bit they walk, and if they drag the dpad out far, they sprint. I want to apply a series of changes to the player when they start sprinting, so just giving them a higher walkspeed by default isn’t enough, I must be able to monitor changes to the dpad.

Is there a built in way to do it? Ideally I’d like the magnitude between the start of the press, and where the touch currently is.

Thanks!

you can get the players MoveVector which returns a Vector3 where the X and Z values will change based on the direction the player is moving in and the Y value will always be 0. On a computer, the X and Z values are set to 0 if the player is not moving in that direction, 1 if the player is moving backwards or left, and -1 if the player is moving right or forwards. But on mobile, the value will change based on the position of the Thumbstick/Thumbpad.

Here is how to get the MoveVector:

Check for these scripts in StarterPlayerScripts

  1. A ModuleScript named “PlayerModule”
  2. a LocalScript named “ControlScript” with a ModuleScript named “MasterControl” inside of it

You can do the movement adjustments by making a new LocalScript in StarterPlayerScripts

If you have the PlayerModule in StarterPlayerScripts or you don’t have any of the scripts listed above, you would put

local Control = require(LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"):WaitForChild("ControlModule"))

if you have the LocalScript named “ControlScript” with the “MasterControl” ModuleScript inside of it then you want to do this:

local Control = require(LocalPlayer.PlayerScripts:WaitForChild("ControlScript"):WaitForChild("MasterControl"))

now you can get the MoveVector:

local MoveVector = Control:GetMoveVector()

then you can get the Vector3 value and return it or do whatever you need to do with it or you can get the X,Y and Z values individually with MoveVector.X, MoveVector.Y or MoveVector.Z