Problem with the Dash system

Hello everyone!

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?

Thank you in advance!

3 Likes

Hey there. Just a question on how can we help you without you providing us with vital information like images, videos and most of all the script. Hm?

1 Like

Here:

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)
2 Likes

And how to solve the problem with the fact that when the player is on the ground, the pulse speed is much lower?

For that you can add a bodyforce or vectorforce on the player to make a sort of anti-gravity effect. See this video by @okeanskiy

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.