BodyAngularVelocity slightly curving balls trajectory near end of travel


#1

I have a ball that needed to be slowed down, so I used BodyAngularVelocity. Without it, the balls path is always just straight unless acted upon by an obstacle. But with the Body, when the ball is nearing a stop, it curves very subtly.

Anyone encounter this before?


#2

I’ve been keeping up with your posts, and I might’ve came up with a system that could work for you. Here it is, hope you don’t mind that it isn’t formatted, it’s just super hard to write up code using the 4-space thing, it usually looks terrible every time I try it. This script would assume to be inside your ball object. Two other notes, I didn’t test this, and I didn’t take in account for Y velocity.

local slowing_down = false

local delta = .1 --Value/speed for the for loop. Too small of a number may provide you with float inaccuracies.

local function slow_down()
   for x = 0,1,delta do
      script.Parent.Velocity = Vector3.new(script.Parent.Velocity.X * (1 - x),script.Parent.Velocity.Y,script.Parent.Velocity.Z * (1 - x))
      wait()
   end
   slowing_down = false
end

script.Parent.Changed:Connect(function()
   local vel = script.Parent.Velocity
   if not slowing_down and (math.abs(vel.X) > 0 or math.abs(vel.Z) > 0) then
      slowing_down = true
      slow_down()
   end
end)

#3

Manually changing the velocity and rotvelocity like this hasn’t worked for me, it has had no effect on the ball whatsoever.

Thanks though.


#4

I believe this is related to rotational velocity. When I set the torque in the BodyAngularVelocity to say 100,100,100, it prevents the ball from rotating at all, and this curving doesn’t occur.

Unfortunately for me, I would like the ball to roll.