I have been working on a dash that moves the player in the direction of their mouse using mouse.hit for the Y axis and the LookVector of their root part for the X and Z axis on a BodyVelocity. The basic code functions almost exactly how I want it, however, the player can move their mouse and change their direction mid dash, which is not what I want.
local humanoid = player.Character.Humanoid
local rootPart = player.Character.HumanoidRootPart
local vel = Instance.new("BodyVelocity")
humanoid.WalkSpeed = 0
vel.Parent = rootPart
vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
vel.Velocity = Vector3.new(rootPart.CFrame.LookVector.X * 50, mouseHitY * .01, rootPart.CFrame.LookVector.Z * 50)
wait(dashTime.Value)
vel:Destroy()
humanoid.WalkSpeed = 16
I suppose I have two questions: Is there a simple way of just disabling mouse movement for the duration of the dash to prevent the unwanted movement, or is there a better way of moving the player forward in the direction of the mouse to achieve my desired results? My camera is third person, over the shoulder with cursor locked to the center of the screen, if it matters.