#Smooth dashes in my battlegrounds game
1 messages · Page 1 of 1 (latest)
Here is my script:
if Knit.GetService("StateService"):GetState("Stunned") then return end
local hrp: Part = player.Character:FindFirstChild("HumanoidRootPart")
local dv = Instance.new("BodyVelocity")
dv.MaxForce = Vector3.new(10000, 10000, 10000)
dv.Parent = hrp
local dashStrength = 100
local minimumDashStrength = dashStrength * 0.15
local amountOfIterations = DashController.DashDuration / DashController.Rate
local removalOfStrengthPerIteration = dashStrength / amountOfIterations
for _, part in player.Character:GetChildren() do
if part:IsA("BasePart") then
part.Massless = true
end
end
for i = 0, DashController.DashDuration, DashController.Rate do
local forwardVector = workspace.CurrentCamera.CFrame.LookVector
local targetRotation = math.atan2(forwardVector.X, forwardVector.Z) + math.pi
hrp.CFrame = CFrame.new(hrp.Position) * CFrame.Angles(0, targetRotation, 0)
if dashDirection == "Front" then
dv.Velocity = hrp.CFrame.LookVector * dashStrength
elseif dashDirection == "Back" then
dv.Velocity = (hrp.CFrame.LookVector * -1) * dashStrength
elseif dashDirection == "Right" then
dv.Velocity = hrp.CFrame.RightVector * dashStrength
elseif dashDirection == "Left" then
dv.Velocity = (hrp.CFrame.RightVector * -1) * dashStrength
end
if dashStrength > minimumDashStrength then
dashStrength -= removalOfStrengthPerIteration
if dashStrength < minimumDashStrength then
dashStrength = minimumDashStrength
end
end
task.wait(DashController.Rate)
end
for _, part in player.Character:GetChildren() do
if part:IsA("BasePart") then
part.Massless = false
end
end
dv:Destroy()
I'm assuming my 1st issue is something to do with part.massless
Smooth dashes in my battlegrounds game
bodyvelocity is deprecated. ik it sucks but it's better to use linearvelocity (from what i remember it auto handles gravity but i'm not sure)
Oh does it? In that case I'll try and learn it
it works i believe the same as bodyvelocity but it's a bit better?
it has 3 different modes for the velocity
lemme find the documentation and send it to u
also keep forcelimitsenabled as false it's a bit buggy
Oh good to know!