Making a rigidbody never sleep

hello guys,

how can I tell a rigidbody to stay awake all the time and never sleep?

does setting the sleepVelocity = 0 guarantees 100% that the rigidbody will not sleep?

is there a better way for doing so?

thanx for all help,
Firas.

I would assume a sleep velocity of 0 would work. If not, you could this in FixedUpdate:

if (rigidbody.IsSleeping() ) {
    rigidbody.WakeUp();
}

More discussion on the issue in this thread.

2 Likes

thanx Matthew,

the thing is that I was trying to avoid the wakeup on every fixed frame.

the only thing I found other than that is setting the sleep velocity to 0, a neater, probably more efficient solution.

I tried it and it worked; but maybe because the velocity approached 0 but is not exactly 0.

the question is:

is setting the sleep velocity to 0 guarantees 100% that the object will never sleep throughout? if not, is there a clean solution to achieve this?

thanx guys,
cheers,
Firas

1 Like

You can use

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

this worked for me

3 Likes