Help with decelerating part

I am currently using the parts velocity to move the part around using the mouse position look vector, however once a force is applied on the part it never stops. I have no idea how to stop with a Vector3

while game:GetService("RunService").Heartbeat:Wait() do
	if Acceleration == true then

		Ball.Velocity += Vector3.new(-100,0,100)
	end
	if Ball.Velocity.X > 0 or Ball.Velocity.Z > 0 then
		Acceleration = false
	end
end

Currently, when ever I try to decelerate it with this code it just accelerates instead depending on were the mouse position was. Can someone help.

Just set the velocity of the object to Vector3.zero

1 Like

But then the ball won’t even accelerate and will just say idle. I want a smooth deceleration to 0 not an instant stop in force. Tweening is also not an option too.

Then use :ApplyImpulse()
ApplyImpulse

BasePart:ApplyImpulse() dosen’t stop the velocity of an object, instead it applies an instant impulse and then slowly decelerates the object.

1 Like

would there be an alternative because I would want to be able to configure how fast the ball decelerate at, which I’m not sure BasePart:ApplyImpulse() can do.

I don’t think there are any constraints that do that, however you could instead do something like


local velocityTarget = Vector3.zero
local velocityReduction = Vector3.new(-1, 0, -1)

repeat 
    BasePart.AssemblyLinearVelocity += velocityReduction 
    game:GetService("RunService").Stepped:Wait()
until BasePart.AssemblyLinearVelocity == velocityTarget 

It doesn’t work and instead it continues to accelerate, thank you for the help.

Have you changed the velocityReduction ?

yes, I have still the same problem

Oh, wierd. Can I see your code?

If you wanted to do that, you will need a specific goal

how would I implement a specific goal to set the AssemblyLinearVelocity to 0 on this code.

You could save the time from when you accelerated, and then you decelerate after a given amount of seconds