I’m essentially looking to get a Vector2 value based upon where the mobile player drags their thumbstick:
How would go about approaching this?
I’m essentially looking to get a Vector2 value based upon where the mobile player drags their thumbstick:
How would go about approaching this?
You could try measuring using the studio ‘UI’.
I believe you can use UserInputService.InputChanged for the ThumbstickMovement InputObject. The position value should be stored in InputObject.Position
You can use this member of the control script:
local GetMoveVector = require(player:WaitForChild("PlayerScripts"):WaitForChild("ControlScript").MasterControl).GetMoveVector
e.g. local direction = GetMoveVector()
It will still give you a direction if you’re not on mobile. (It won’t give you the direction if PlatformStand is true.)
The thumb-pad is simply created in the Player.PlayerScripts.ControlScript.MasterControl.Thumbstick script. It listens to Enum.UserInputType.Touch, and maps it onto the thumbstick GUI created there. Analogously, the equivalent keyboard control script listens to Enum.PlayerActions.CharacterForward etc. (So controlling the ContextActionService with the Thumb-pad would be the ‘wrong way’.)
In the end, the MasterControl script sends the MoveValue variable to the Player.Move() function. So I found that in the player’s humanoid, this value comes back as Humanoid.MoveDirection, even in Platform stand. @ForeverHD
I think I’ll have a go at something based off this, thank you.
You will want to use GetMoveVector, not interpreting the UI object directly, that is hacky and prone to change since the UI hierarchy/layout of the control UI is not guaranteed. GetMoveVector is more guaranteed to be always present and you won’t be duplicating code that the control scripts are already doing to calculate the move vector.
hey, sorry to necro the topic, but i tried doing that and i get this error.
Players.GregTame.PlayerScripts.PlayerModule.ControlModule:150: attempt to index local 'self' (a nil value)
do i need to pass something to the GetMoveVector?
sorry, i am an absolute dingus when it comes to MetaTables, and i don’t know the first thing about them.
Sorry for the late reply, I just wanted to clear it out though. Roblox has updated the PlayerModule since february 2019 so you need to do it deffrently now. They’ve removed mastercontrol and replaced controlscript with controlmodule which is placed inside the PlayerModule. Now instead of doing something like this: local GetMoveVector = require(player:WaitForChild("PlayerScripts"):WaitForChild("ControlScript").MasterControl).GetMoveVector
You whould do like this:local GetMoveVector = require(player:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule")):GetMoveVector() print(GetMoveVector)
That is what I use for my games. And what you probably should use. Notice how they changed “.GetMoveVector” to “:GetMoveVector”.