LinearVelocity makes player go up when hitting a wall

Trying to make a dash system for my battlegrounds game. Everything works perfectly expect one thing - when you using the dash against a wall, you starting getting up against it.

Also somehow, the dashes that going in left or right directions won’t fling you, but the dash forward and back will fling you

Here’s the part of the code that creates LinearVelocity:

function CreateVelocity(TweenLength, Length, Force, HumanoidRootPart)
	local Attachment = Instance.new("Attachment", HumanoidRootPart)
	Attachment.WorldPosition = HumanoidRootPart.AssemblyCenterOfMass
	Attachment.Name = "VelocityAttach"

	local Velocity = Instance.new("LinearVelocity", HumanoidRootPart)
	Velocity.ForceLimitsEnabled = true
	Velocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
	Velocity.MaxAxesForce = Vector3.new(100000, 0, 100000)
	Velocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
	Velocity.Attachment0 = Attachment
	Velocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
	Velocity.VectorVelocity = Force

	TweenService:Create(Velocity, TweenInfo.new(TweenLength, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {VectorVelocity = Vector3.new(0, 0, 0)}):Play()

	coroutine.wrap(function()
		task.wait(Length)

		if Velocity and Attachment then
			Velocity:Destroy()
			Attachment:Destroy()
		end
	end)()
end

And here are the directions of dashes (VectorVelocity):

	local Directions = {
		["Enum.KeyCode.W"] = Vector3.new(0, 0, -100),
		["Enum.KeyCode.A"] = Vector3.new(-100, 0, 0),
		["Enum.KeyCode.S"] =  Vector3.new(0, 0, 100),
		["Enum.KeyCode.D"] = Vector3.new(100, 0, 0),
	}

Is there anyway to make it work like in other battlegrounds games? “The Strongest Battlegrounds” for example.

1 Like

Use a raycast to prematurely destroy the force if you happen to hit an obstacle

1 Like

not even working

still thanks

chars chars chars chars chars

I tested and it worked for me. Maybe tweak it with your system? Anyways i told you why it happens soo i hope you can fix it

Btw you didnt even need to create a raycast; you literally could’ve just lowered the maxforce (just for future reference)

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