I am creating a dash system for my fighting game, and when you dash, I want you to be able to sort-of steer the way you want to dash and it keeps all your momentum, like how Your Bizarre Adventure, The Strongest Battlegrounds, and Blox Fruits does it. My solution to this originally was using VectorForce, but I realized when I dash whilst airborne, I go 10x farther than a normal dash. Is there any alternative/way to fix this?
dashBind.Event:Connect(function()
local dashVelocity = 15000
local velocity = Instance.new("VectorForce", hrp); velocity.Attachment0 = hrp:WaitForChild("RootAttachment")
velocity.ApplyAtCenterOfMass = true
local dashAnimation = Instance.new("Animation"); game.Debris:AddItem(dashAnimation, 1)
if uis:IsKeyDown("W") or not running then
dashAnimation.AnimationId = "rbxassetid://"..dashAnimations[1]
velocity.Force = Vector3.new(0,0,-dashVelocity)
elseif uis:IsKeyDown("S") then
dashAnimation.AnimationId = "rbxassetid://"..dashAnimations[2]
velocity.Force = Vector3.new(0,0,dashVelocity)
elseif uis:IsKeyDown("D") then
dashAnimation.AnimationId = "rbxassetid://"..dashAnimations[3]
velocity.Force = Vector3.new(dashVelocity,0,0)
elseif uis:IsKeyDown("A") then
dashAnimation.AnimationId = "rbxassetid://"..dashAnimations[4]
velocity.Force = Vector3.new(-dashVelocity,0,0)
end
game.Debris:AddItem(velocity, .3)
local dashTrack = hum:LoadAnimation(dashAnimation); dashTrack:Play()
local dashSound1 = Instance.new("Sound", hrp); dashSound1.SoundId = "rbxassetid://6128977275"; dashSound1.Volume = 1.5; game.Debris:AddItem(dashSound1, 3); dashSound1:Play()
local dashSound2 = Instance.new("Sound", hrp); dashSound2.SoundId = "rbxassetid://3084314259"; dashSound2.Volume = .7; game.Debris:AddItem(dashSound2, 1); dashSound2:Play()
local trailDecay = .7
local a1 = Instance.new("Attachment", hrp); a1.Position = Vector3.new(0,.2,0); game.Debris:AddItem(a1, trailDecay)
local a2 = Instance.new("Attachment", hrp); a2.Position = Vector3.new(0,-.2,0); game.Debris:AddItem(a2, trailDecay)
local trail = Instance.new("Trail", hrp); trail.Attachment0 = a1; trail.Attachment1 = a2; game.Debris:AddItem(trail, trailDecay); trail.Color = ColorSequence.new(Color3.new(0.85098, 0.85098, 0.85098)); trail.Lifetime = .2
end)