Spherical rigid body will never stop rolling regardless of drag

My problem is that I have a rigid body with a spherical collider and once it starts moving (rolling) it never stops.

I have read other answers here which state that changing the drag (angular and normal) is the answer to this problem but I must be doing something wrong somewhere else. I have been experimenting with this for hours and cant find a solution.

I have moved the drag to a million, still moves but very very slowly. I have moved the angular drag to a million with similar results. I have set the sleepThreshold to a high number. This didnt seem to do anything. I tried changing the friction on the terrain.

I placed the ball on a flat, horizontal plane for all of these tests and applied an impulse to start it moving. It has never come to a stop yet.

There are times when it reaches a certain velocity and then stutters like it is about to stop and then it starts moving at a constant velocity forever, I think I can visibly observe the shift from deceleration to constant velocity. It doesnt make any sense to me at all.

It is my assumption that the ball should stop eventually and that unity, being so advanced, would handle this easily but its possible that I’m missing something due to being so new.

To offer a workaround, simply apply your own opposite force proportional to the actual velocity of the sphere. It only needs to be small. It is basically simulating drag. It will ensure that at all velocities there is a reaction force. This guarantees to slow down the rigidbody over time.

When it is a fraction of the velocity when velocity is 0 the opposite force will also be zero, so no force will be applied and the ball wont start randomly rolling off.

As @Majellin states “This shyet shouldn be happenin, yo”. And he’s right.


EDIT: Using the above theory didnt make the rigidbody stop rolling, but I did eventually find a way to make it stop.

By default the inertiaTensorRotation is set to Quaternion(0,0,0,1). simply changed this value to something small; Quaternion(0.01, 0.01, 0.01, 1) and the damnable thing stopped, with the aid of my snippet.

#pragma strict

var rb : Rigidbody;
var scaler : float = 0.1;

function Start ()
{
	rb = GetComponent(Rigidbody);
	rb.sleepThreshold = 0.01;
}

function FixedUpdate ()
{
	//Debug.Log(rb.angularVelocity.x + " : " + rb.angularVelocity.y + " : " + rb.angularVelocity.z);
    rb.inertiaTensorRotation = Quaternion(0.01, 0.01, 0.01, 1);
	rb.AddTorque(-rb.angularVelocity * scaler);
}

I had initially placed rb.inertiaTensorRotation = inside the Start() function but realised that the value was being reset to 0 every frame. I had to move this to the loop so it was set to a value just before I made each AddTorque call. Actually, spamming the rb.inertiaTensorRotation was enough to make the ball stop on its own.

Perhaps I found the bug here.

Try it and see if it works for you!

I had this issues as well and after spending some time we have discovered that constantly setting the rigidBody.mass for the sphere at the start of FixedUpdate makes this problem go away.

I fixed the problem by setting angular drag to around 5.,I fixed the problem by setting the angular drag to 5. drag is 0.

Now the ball behaves normally, it stops when rolling after a time.

EDIT: It still rolled with a very very low velocity for ever. I added this code to make it stop.

void FixedUpdate ()
{
if (rigid.velocity.magnitude < 0.1f)
rigid.velocity = Vector3.zero;
}

There could be two reasons, either your ball is not using Gravity or it is Kinematic … if these two reasons are not what making your BALL moving constantly, then possibly your are constantly applying the ADDFORCE in Update or FixedUpdateOR YOU'VE APPLIED A PHYSICS MATERIAL WITH NO DRAG