2D Movement doesnt work in mobile

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want it to make a 2d movement that works in both pc and mobile
  2. What is the issue? Include screenshots / videos if possible!
    i tried using contextactionservice to disable movement forward and back but it didnt work in mobile
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    what i have found that you need to make buttons for the mobile in order for it work do i have to do the same?
game:GetService("ContextActionService"):UnbindAction("moveForwardAction")
game:GetService("ContextActionService"):UnbindAction("moveBackwardAction")
1 Like

You have to do this first so that the functions actually bind for you to unbind them after.

require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
1 Like

I tried what you told me but i didnt work

1 Like

Personally I would just manually set the z axis of the character.

Like so:

local TargetZ = 0
local Character = script.Parent
local RootPart = Character.HumanoidRootPart

game:GetService("RunService").Heartbeat:Connect(function()
	RootPart.CFrame += Vector3.new(0, 0, TargetZ-RootPart.Position.Z)
end)
2 Likes

Like this way?

require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))

game:GetService("ContextActionService"):UnbindAction("moveForwardAction")
game:GetService("ContextActionService"):UnbindAction("moveBackwardAction")
1 Like

yes i did excatly what you told me

Does it affect any other movement directions? Like does moving left not work

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.