Seeking Advice on Handling Player Deacceleration in My Movement System

I’m currently working on a movement system for my game, and I’ve encountered a bit of a challenge. I’ve implemented a deacceleration mechanism for when the player stops, and I’m using a BodyVelocity for this purpose. However, I’ve run into an issue: when the player jumps in the air and then stops, they get stuck in mid-air. Is there anyway to fix this, or to go by doing it differently?

Deacceleration part of the script:

function CharacterHandler:ApplyDeceleration()
	if not self.isMoving and self.lastMoveDirection then
		local characterRoot = self.Character:FindFirstChild("HumanoidRootPart")
		if characterRoot then
			local bodyVelocity = Instance.new("BodyVelocity")
			self.deaccelerationTween = TweenService:Create(bodyVelocity, TweenInfo.new(DEACCELERATION_TIME, Enum.EasingStyle.Sine, Enum.EasingDirection.In), { Velocity = Vector3.new(self.lastMoveDirection.X * FRICTION, 0, self.lastMoveDirection.Z * FRICTION) })
			bodyVelocity.MaxForce = Vector3.new(10000, 10000, 10000)
			bodyVelocity.Velocity = Vector3.new(self.lastMoveDirection.X * FRICTION, 0, self.lastMoveDirection.Z * FRICTION)
			bodyVelocity.Parent = characterRoot
			self.deaccelerationTween:Play()

			self.deaccelerationTween.Completed:Connect(function()
				bodyVelocity:Destroy()
			end)
		end
	end
end

The MaxForce of the BodyVelocity applies force in the Y direction which will cause deacceleration on the Y axis. This can be fixed by setting the Y of the MaxForce to 0.

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