I’m making an 2D game and since there is a 2D perspective, the player shouldn’t be able to move left and right. So I tried unbinding the left and right moving.
So when I hold W the player shouldn’t move forward (from the 2D perspective) right? Wrong. If you press W and any other button that makes the player walk diagonal, then the player can move forward again even if you let go of the other button and keep holding W.
I couldn’t find anyway to fix this, and that’s why I’m asking here.
Here is the script that I use for both the camera and the unbind action :
local cam = workspace.CurrentCamera
local char = script.Parent
local hrp = char:WaitForChild("HumanoidRootPart")
local ContextActionService =game:GetService("ContextActionService")
local FowardMovement = Enum.PlayerActions.CharacterForward
local BackwardMovement = Enum.PlayerActions.CharacterBackward
local function Sink()
return Enum.ContextActionResult.Sink
end
ContextActionService:BindAction("SinkFowardMovement", Sink,false,FowardMovement)
ContextActionService:BindAction("SinkBackwardMovement",Sink,false,BackwardMovement)
game:GetService("RunService").RenderStepped:Connect(function()
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = cam.CFrame:Lerp(CFrame.new(hrp.Position + Vector3.new(0, 3, 10), hrp.Position), 0.1)
end)