Body Velocity Issue

  1. I want my Dash script to not cause the flying issue in this video

  2. When dashing into a small object or object with unusual curves it sends the player up

  3. Tried messing with the BV values to no avail

This is a server Script

local char = script.Parent.Parent
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")

local SideGyro = Instance.new("BodyGyro")
SideGyro.MaxTorque = Vector3.new(3e5,0,3e5)
SideGyro.P = 5e5
SideGyro.Parent = hrp

local DashSpeedPerm = 65
local DashSpeed = 65
local DashLength = 8

local sideDashCooldown = 0.75
local pivitalDashCooldown = 1.25

local sideDebounce = false
local pivitalDebounce = false

-- STATES
local dashing = char:WaitForChild("STATES"):WaitForChild("Movement"):WaitForChild("Dashing")

local Animations = {
	["DashRight"] = 'rbxassetid://135911084922934';
	["DashLeft"] = 'rbxassetid://81447650120538';
	["DashFront"] = 'rbxassetid://113320811106767';
	["DashBack"] = 'rbxassetid://131062322489558';
}

for i,v in pairs(Animations) do
	local Anim = Instance.new("Animation")
	Anim.AnimationId = v
	Anim = hum:LoadAnimation(Anim)
	Animations[i] = Anim
end

script.Dash.OnServerEvent:Connect(function(plr, Key)
	
	local dashSFX = plr.PlayerGui.SFX.Movement.Dash
	local landSFX = plr.PlayerGui.SFX.Movement.LandLight
	
	if dashing.Value then
		return
	end

	local DashAnim
	local Front 
	local Side 

	local typeDash

	local cancel

	if Key == Enum.KeyCode.A then
		if sideDebounce then return end
		typeDash = "Side"
		Side=-1.65
		Front = 0
		DashAnim = "Left"
	end

	if Key == Enum.KeyCode.D then
		if sideDebounce then return end
		typeDash = "Side"
		Side=1.65
		Front = 0
		DashAnim = "Right"
	end

	if Key == Enum.KeyCode.W then
		if pivitalDebounce then return end
		typeDash = "Pivital"
		Side=0
		Front = 2
		DashAnim = "Front"
	end

	if Key == Enum.KeyCode.S then
		if pivitalDebounce then return end
		typeDash = "Pivital"
		Side=0
		Front = -1.85
		DashAnim = "Back"
	end

	if typeDash == "Side" then
		sideDebounce = true
	else
		pivitalDebounce = true
	end

	dashing.Value = true
	DashSpeed = DashSpeedPerm

	local cloneSFX = dashSFX:Clone()
	cloneSFX.Parent = char.HumanoidRootPart
	cloneSFX:Play()
	game.Debris:AddItem(cloneSFX, cloneSFX.TimeLength)

	dashing.Value = true
	Animations["Dash"..DashAnim]:Play()

	hum.WalkSpeed = 0
	task.wait(0.1)

	local DashVelocity = Instance.new("BodyVelocity")
	DashVelocity.MaxForce = Vector3.new(math.huge,0,math.huge)
	DashVelocity.P = 9e9
	DashVelocity.Parent = hrp
	DashVelocity.Velocity = hrp.CFrame.LookVector * (Front * DashSpeed) + hrp.CFrame.RightVector * (Side * DashSpeed) 

	local count = 0
	local negatingFactor = DashSpeedPerm/(DashLength)

	repeat wait()
		DashVelocity.Velocity = hrp.CFrame.LookVector * (Front * DashSpeed) + hrp.CFrame.RightVector * (Side * DashSpeed) 
		count += 1
		if DashSpeed ~= 0 and DashSpeed > 0 then
			DashSpeed -= negatingFactor
		end
	until count >= DashLength

	landSFX:Play()
	hum.WalkSpeed = 13

	dashing.Value = false
	DashVelocity:Destroy()
	if typeDash == "Side" then
		task.wait(sideDashCooldown)
		sideDebounce = false
	else
		task.wait(pivitalDashCooldown)
		pivitalDebounce = false
	end

end)

I was thinking of using raycast to see if there is an object where the player is dashing, but I’m not sure if it is viable

just don’t use body velocity…
its a depracated instance
Use LinearVelocity | Documentation - Roblox Creator Hub instead
You should just use HumanoidRootPart:ApplyImpulse() here instead most likely/AllignPosition

I tried LinearVelocity but the problem with it is if the character dashes off a cliff he’s left hanging in the air till the velocity is finished, and ApplyImpulse doesn’t work at all

Give it more momentum

Etc: UnitVector*1000

local direction = (hrp.CFrame.LookVector * (Front * DashSpeed) + hrp.CFrame.RightVector * (Side * DashSpeed))
hrp:ApplyImpulse(direction * 1000)

Not working

Maybe try doing so on a client.
Network ownership issues maybe/give it some upvector or make impulse stronger
try getting mass of assembly and multiplying that by 1000 idk

Yeah that worked, I put the scrip into a local one and just ran it like so:

local direction = (hrp.CFrame.LookVector * (Front * DashSpeed) + hrp.CFrame.RightVector * (Side * DashSpeed))
hrp:ApplyImpulse(direction * 10)
1 Like

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