I made a dash system through BodyVelocity instance, but when a player collides with an object during a dash, he accumulates vertical speed and calls up. I would like this not to happen, how can it be implemented?
local Character = Player.Character or Player:CharacterAdded:Wait()
local BodyVelocity = nil
local DashInfo = {
DashBind = Enum.KeyCode.Q;
DashCD = false;
Cooldown = 0.8;
Duration = .1;
}
Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
local function Dash(_, InputState, _)
if InputState == Enum.UserInputState.Begin then
if not DashInfo.DashCD and Character:FindFirstChild("HumanoidRootPart") then
DashInfo.DashCD = true
local HumanoidRootPart = Character.HumanoidRootPart
local LookVector = HumanoidRootPart.CFrame.LookVector
DashAssets.BodyVelocity = Instance.new("BodyVelocity", HumanoidRootPart)
DashAssets.BodyVelocity.MaxForce = Vector3.new(math.huge, 0, math.huge)
DashAssets.BodyVelocity.Velocity = LookVector * 70
task.wait(DashInfo.Duration)
DashAssets.BodyVelocity:Destroy()
task.wait(DashInfo.Cooldown)
DashInfo.DashCD = false
end
end
end
Context:BindAction("Dash", Dash, false, DashInfo.DashBind)
May I ask why your using BodyVelocity and not BasePart:ApplyImpulse() or BasePart.Velocity?
So it would be:
local Character = Player.Character or Player:CharacterAdded:Wait()
local BodyVelocity = BodyVelocity = nil
local DashInfo = {
DashBind = Enum.KeyCode.Q;
DashCD = false;
Cooldown = 0.8;
Duration = .1;
}
Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
local function Dash(_, InputState, _)
if InputState == Enum.UserInputState.Begin then
if not DashInfo.DashCD and Character:FindFirstChild("HumanoidRootPart") then
DashInfo.DashCD = true
local HumanoidRootPart = Character.HumanoidRootPart
local LookVector = HumanoidRootPart.CFrame.LookVector
HumanoidRootPart:ApplyImpulse(LookVector*70)
task.wait(DashInfo.Cooldown)
DashInfo.DashCD = false
end
end
end
Context:BindAction("Dash", Dash, false, DashInfo.DashBind)