Player Dashing that always travels the same distance

I want to create a robust forward dash/roll that will bring the player forward. I’ve tried a couple methods, but they all end up going too far when the player is in the air compared to the short distance they travel on land. I used BodyVelocity and a CFrame loop, but they both did not yield good results.

Anyone know a good method for dashing that will travel the same distance no matter what physics or friction the player is under? I don’t want players to travel 20 studs just because they dashed in the air.

3 Likes

Maybe, making an animation for it will work for your needs. That way the player that is dashing will always have the same travel distance and “movements” with no ( or little to non) interaction with physics.

Try setting the humanoid’s PlatformStanding value to true while dashing. I believe this will solve your problem.

If I set the humanoid’s PlatformStanding to true, wouldn’t it just flop on to the floor while dashing? If I pair this with BodyVelocity, it would also just kinda fling forward. What do you suggest I pair PlatformStanding true with to push the player forward?

If I use animations, it’ll move forward, but after the animation’s done it will go back to the original position.

Instead of using BodyVelocity, set the player’s root velocity to a certain value to move them forward.

-- setting the character and speed of dash
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local vel = 300

-- grabbing the User Input Service
local UserInputService = game:GetService("UserInputService")


-- detecting when they want to dash

local can_dash = true
local cooldown = 3

UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
    if can_dash == true then
        Char.HumanoidRootPart.Velocity = char.HumanoidRootPart.CFrame.lookVector * vel
        can_dash = false
        wait(cooldown)
        can_dash = true
    end
end
    

if plr_wants_to_dash then -- detect when they want to dash (can use UserInputService)
    Char.HumanoidRootPart.Velocity = char.HumanoidRootPart.CFrame.lookVector * vel
end
2 Likes

I’ve applied this to UserInputService with the keybind Q.

GIF of the code you sent in action

It floats up a bit, but doesn’t go forward. That’s about it…

Look at the new edit I made, and this time forget about platformstanding. :slight_smile:

Well, not exactly, there are ways to have the character not go back to the start position once the animation is done

but you can use velocity and body movers to achieve this( but its not as accurate and “concise” )

Other Discussions pertaining to this:

This definitely dashes, but it goes back to my original issue, which is that players move farther in the air than on ground because of the friction. Check the GIF below to see what I mean.

GIF of dashing in air and on ground

1 Like

Personally, I would use bodyVelocity but since it isn’t suitable for your case, have you considered manually changing their CFrame via tweenService?

1 Like

I haven’t tried it with TweenService, but I have done it with a CFrame for loop. If I use TweenService, would I be able to keep it only on the Z and X axis, so that the player can move with gravity while dashing?

The friction of the part is slowing the player down. You can try removing the friction of the part beneath the player locally.

But with an AnimationTrack, the HumanoidRootPart does not follow where the animation goes. For example, my camera wouldn’t move with the player, and if I used mouselock I could change the dash’s direction midway, which is pretty weird.

1 Like

Why not lock a part relative to the player that serves as the endPoint for the tween. That way you can dictate what direction the player goes :slight_smile:

1 Like

The tween will not account for gravity, but most dashes in games don’t anyway.

If I remove the friction, wouldn’t it just slide for a really long time? Haven’t tested but that’s what I expect to happen.

I have heard that using BodyPosition, not Velocity, is effective for this kind of stuff. Haven’t tried it myself though.

You can set the friction back once the dash is over.

I recommend @Ukendio 's dash method with the tweening, and the locked part to the player to determine where to send them!

Edit: though I must say it will move for a certain distance until it falls out of the air.

1 Like

Hmm… I don’t want the dash to ignore gravity completely. I think what I need is a BodyPosition mover that ignores the Y axis, would this be possible? I know the type of dash I’m looking for is possible, as I’ve seen it in games before.