#Dash system

1 messages · Page 1 of 1 (latest)

reef wing
#

I was wondering if there is a way to make dashes similar to tsb's, because they are fluid and fast, you can hardly notice when you delete the body velocity, normally I made a system something like this:


local bv = Instance.new("BodyVelocity", Character.HumanoidRootPart)
bv.P = 2000
bv.MaxForce = Vector3.new(100000, 0, 100000)

local value = Instance.new("NumberValue")
value.Value = 100 -- multiplier

local dashConn
dashConn = RunService.RenderStepped:Connect(function()
local RightVector = Character.HumanoidRootPart.CFrame.RightVector
bv.Velocity =  RightVector * value
end)

TweenService:Create(value, TwenInfo.new(0.75), {Value = 0})
Debris:AddItem(bv, 0.74)

task.delay(0.75, function()
dashConn:Disconnect()
end)

but it doesn't have the same fluidity that tsb has, what would you recommend to make it more similar, at the moment it looks like this:

silk rain
novel breach
#

you can change the parameters but i got a smooth looking dash to work

#

i used LinearVelocity instead of BodyVelocity and changed the VelocityContstraintMode to Line, then when you dash you just tween the right vector along with the dash value/speed

#

here is my local script in StarterCharacterScripts

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
local RootAttachment = HumanoidRootPart:WaitForChild("RootAttachment")

local DASH_SPEED = 50
local DASH_TIME = 0.75
local CAMERA_SPEED = 4
local DASH_FORCE = 100000

UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.KeyCode==Enum.KeyCode.E then
        local linearVelocity = Instance.new("LinearVelocity")
        linearVelocity.Parent = HumanoidRootPart
        linearVelocity.MaxForce = DASH_FORCE
        linearVelocity.Attachment0 = RootAttachment
        linearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Line
        local startTime = os.clock()
        local rv = workspace.CurrentCamera.CFrame.RightVector
        local connection = RunService.RenderStepped:Connect(function(d)
            local progress = math.clamp((os.clock()-startTime)/DASH_TIME,0,1)
            d=math.clamp(d,0,1)
            rv=rv:Lerp(workspace.CurrentCamera.CFrame.RightVector,d*CAMERA_SPEED)
            local value=DASH_SPEED+(0-DASH_SPEED)*(progress)
            linearVelocity.LineDirection=rv
            linearVelocity.LineVelocity=value
        end)
        task.wait(DASH_TIME)
        linearVelocity:Destroy()
        connection:Disconnect()
    end
end)
reef wing