I have an effect in my game that makes the player unable to move or jump temporarily. The problem is this doesn’t work on mobile players who use the dyanmic joystick
Mobile players don’t like it when the joystick disappears and they have to put their hand on it again, so making it disappear is not a good option.
I’ve searched and searched but no answers have solved my exact problem
Setting the player’s WalkSpeed to 0 is a bad idea because there are abilities and effects that change the player’s WalkSpeed, so it would inevitably cause tons of glitches relating to that
local ContextActionService = game:GetService("ContextActionService")
local FREEZE_ACTION = "freezeMovement"
local function bind(value)
if value == true then
ContextActionService:BindAction(FREEZE_ACTION,function() return Enum.ContextActionResult.Sink end, false, unpack(Enum.PlayerActions:GetEnumItems()))
elseif value == false then
ContextActionService:UnbindAction(FREEZE_ACTION)
end
end
if value == true then
bind(true)
elseif value == false then
bind(false)
elseif value == "DelayedFalse" then
repeat wait() until plr.Character
bind(false)
end
Hmm. They find it annoying? I don’t necessarily think hiding the players controls on mobile is a bad thing. Since, it shows the player that he/she is unable to move.
Who exactly finds it annoying? Do you know how many people?
well a friend who plays on mobile says it’s annoying how he has to take his hand of the screen and put it back on in order to move again. I doubt other mobile players will like it
I’m not sure that I’m suggesting this is a good idea… …but if you can’t change WalkSpeed, and you can’t disable the controls, you can do what you want by branching the control system and changing the code in there.
There are future risks to this, because if core code changes your copy of it gets out of sync, so I’d only suggest this if you really must do it and if there’s no better solutions available.
To take a copy run your game in studio. Find your player in explorer, open up playerscripts and copy the PlayerModule. Then stop running and paste that player module into StarterPlayerSciripts
If you then go into your copy of PlayerModule/ControlModule and
function ControlModule:OnRenderStepped(dt) that’s probably where you need to change things
In here you could add some logic to detect that the player is frozen. If you then set the moveVector to be zero I think that would stop all movement. I believe jumping is handled here too, so you can also block that.
As far as I know it would keep the mobile UI, etc. all showing.
Sorry to reply to such an old post, but you could probably anchor the humanoid’s root part to not let the player move, unless you still need them to fall or bounce of something.