Preventing rigidbody sleeping altogether

As the title says, is there any way to completely prevent a rigidbody from sleeping, without having to add 0 force or set their position to their position? Setting the sleep velocity/angular velocity to 0 doesn’t prevent it, once they actually stop moving they go to sleep.

In my scenario I am dropping salt piles to slow & kill slugs that collide with individual salt particles. I use OnTriggerStay to determine if they are touching one and it works, but as soon as the salt particles come to a rest and sleep they stop detecting collisions.

I’ve looked up a few other similar questions and they all seem to have solved it by doing stuff like this:

transform.position = transform.position;

There will potentially be hundreds of salt particles on the screen at a time, I don’t want to have to throw them into a list and loop through it every frame just to set their position to where it already is or add no force, then remove them when they’re dissolved. The slugs aren’t using rigidbodies, I didn’t want them able to push the salt around though I may just end up doing that if there’s no way to prevent sleeping without executing some code every frame.

I ended up with this:

void Update () {
	if (rigidbody.IsSleeping())


My player object doesnt move - the scenery moves towards it, so it would fall asleep pretty quickly and didnt collide with anything. I only had a rigidbody on the player, not the objects, and a sleeping player was the problem!

You can set Rigidbody.sleepThreshold to 0 to prevent rigidbody sleeping.

    m_Rigidbody = GetComponent<Rigidbody>();
    m_Rigidbody.sleepThreshold = 0.0f;

I believe “rigidbody.WakeUp();” is the best solution, but I think it should go in FixedUpdate, with perhaps [DefaultExecutionOrder(-100)] to have it run before other FixedUpdate instances for that rb.

Better to solve the issue on an individual basis than reduce Rigidbody.sleepThreshold globally and incur all of that physics performance hit.

My timer testing suggests WakeUp is much faster than “thisTransform.position = thisTransform.position” (cached transform).

You can use

void Start()
  this.GetComponent<Rigidbody>().sleepThreshold = 0.0f;

this worked for me