Humanoid movement stopping momentum mid air

I have this momentum code and when you are mid air and press a movement key the momentum force gets paused mid air since the humanoid movement force overlaps the momentum force

local function ApplyMomentum(dt)
	local vel = GetHorizontalVelocity()
	local moveDir = Camera.CFrame:VectorToWorldSpace(controlModule:GetMoveVector())
	local isAirborne = Humanoid.FloorMaterial == Enum.Material.Air
	
	if not isAirborne then
	--	controlModule:Enable(true)
	end
	
	if isAirborne then
		--controlModule:Disable()
	
		local desired = vel

		if moveDir.Magnitude == 0 and LastGroundVel then

			desired = Camera.CFrame:VectorToWorldSpace(LastGroundVel)
		end

		if moveDir.Magnitude > 0 then
			desired = vel + (moveDir * CharacterSettings.AirControl * dt)
		end

		desired = ClampMagnitude(desired, CharacterSettings.MaxAirSpeed)
		
		HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(
			desired.X,
			HumanoidRootPart.AssemblyLinearVelocity.Y,
			desired.Z
		)
	else
	
		--controlModule:Enable(true)
		LastGroundVel = Camera.CFrame:VectorToObjectSpace(vel)
	end
end

Alr fixed it i made it use a linear velocity and forthe gravity i just substracted the y with (gravity * dt)

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