I have a dash system, that only has a backwards dash for now. I’m using a thing I found on DevForum to detect if the player is moving left right back or forward. It works completely fine. But when It comes to the body velocity I’m using. It just isn’t doing it right.
It’s hard to explain w/o a video so heres a video
as you can see in the bottom right, both ways print -0, which is the way im walking.
LOCAL SCRIPT CODE
local function dash(action_name, input_state, input_object)
if input_state == Enum.UserInputState.Begin and not blocking and not stunned and can_dash and not attacking then
local movedir = HumanoidRootPart.CFrame:VectorToObjectSpace(Humanoid.MoveDirection)
local yDirection = math.atan2(movedir.X,movedir.Z)
local roundedDirection = math.ceil(math.deg(yDirection) - 0.5)
if roundedDirection <= -0 and roundedDirection >= -70 then
print("backwards dash")
local BODYVELOCITY = Instance.new("BodyVelocity")
BODYVELOCITY.Parent = Character.PrimaryPart
BODYVELOCITY.MaxForce = Vector3.new(math.huge,0,math.huge)
BODYVELOCITY.Velocity = HumanoidRootPart.CFrame:VectorToObjectSpace(CurrentCamera.CFrame.LookVector) * -35
task.wait(0.5)
BODYVELOCITY:Destroy()
end
print(roundedDirection)
end
end