LinearVelocity and gravitation

I want to make dash for my game, but heres a problem is when I make LinearVelocity then It begins ignoring the gravitation of the HumanoidRootPart. I don’t know how to achieve it, because I tried to change settings in it and also tried to make my own system which tries to stabilize the LinearVelocity, but I lost hope to come it true…

here’s small part of code:

local power = (dir == "left" and Vector3.new(-10000, 0, 0)) or (dir == "right" and Vector3.new(10000, 0, 0)) or (dir == "forward" and Vector3.new(0, 0, 0)) or (dir == "back" and Vector3.new(0, 0, 60))
			--local Y
			--local ray
			--local function GetYPowerFromDistance()
			--	local Y2 = 0
			--	ray = functions.DoRay({
			--		FilterType = Enum.RaycastFilterType.Exclude,
			--		PointStart = Player.Character.PrimaryPart.Position,
			--		PointEnd = Player.Character.PrimaryPart.CFrame.UpVector * -10,
			--		FilterDescendantsInstances = {Player.Character, workspace.Living, workspace.Debris},
			--	})
			--	if ray ~= nil then
			--		print(ray.Distance)
			--		if ray.Distance > 2.5 and ray.Distance < 3.0 then
			--			Y2 = 0
			--		else
			--			Y2 = (ray.Distance - 2.5) * -10 
			--		end
			--	else
			--		Y2 = -10
			--	end
			--	return Y2
			--end
			local life_time = (dir == "back" and 0.4) or 0.5
			
			local LinearVelocity = Instance.new("LinearVelocity", Player.Character:FindFirstChild("HumanoidRootPart"))
			LinearVelocity.Attachment0 = Player.Character:FindFirstChild("HumanoidRootPart"):FindFirstChild("RootAttachment")
			LinearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
			LinearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
			LinearVelocity.MaxForce = 1000
			LinearVelocity.LineDirection = power -- + Vector3.new(0, GetYPowerFromDistance(), 0)
			game.Debris:AddItem(LinearVelocity, life_time)

I may be misinterpreting your issue, but:

Try changing the ForceLimitMode property of the LinearVelocity to PerAxis, then set the MaxAxesForce to be Vector3.new(1000, 0, 1000). This sets the vertical force to 0, so it has no impact on gravity!

2 Likes

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