I have this code here that is responsable for the dashing. I realised that the dashing is smooth except for the fact that when the velocity is done. The user stops moving for a moment and it ruins the flow fo the movement any idea how to fix that?
local Velocity = {}
function Velocity.ApplyDashVelocity(humanoidRootPart, dashDirection, dashForce, dashDuration, easingFunction)
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(1, 0, 1) * 80000 -- Only XZ plane
bodyVelocity.P = 12500
bodyVelocity.Parent = humanoidRootPart
local startTime = tick()
local function updateDash()
while tick() - startTime < dashDuration do
local elapsedTime = tick() - startTime
local t = elapsedTime / dashDuration
local easingFactor = easingFunction(t)
local currentLookVector = humanoidRootPart.CFrame.LookVector
local dashDirectionVector = Vector3.new(0, 0, 0)
if dashDirection == "Front" then
dashDirectionVector = currentLookVector
elseif dashDirection == "Back" then
dashDirectionVector = -currentLookVector
elseif dashDirection == "Left" then
dashDirectionVector = -humanoidRootPart.CFrame.RightVector
elseif dashDirection == "Right" then
dashDirectionVector = humanoidRootPart.CFrame.RightVector
end
local targetVelocity = dashDirectionVector.Unit * dashForce * (1 - easingFactor)
bodyVelocity.Velocity = targetVelocity
task.wait()
end
bodyVelocity.Velocity = Vector3.new(0, 0, 0)
bodyVelocity:Destroy()
end
task.spawn(updateDash)
end
return Velocity