- Home /
Problem using sleepvelocity.
If I understand it right, sleepVelocity will force freeze/sleep a rigidbody when its velocity is below the set value?
I created a gameobject->sphere, added a rigidbody to it and the script below. Then I bounce with a player controlled ball gainst it,with such high sleep value it should fall back to sleep right away no? Instead it very slowly comes to a stop.
function Awake() { rigidbody.sleepVelocity = 100; rigidbody.sleepAngularVelocity = 100; }
function Update() { print(rigidbody.velocity.magnitude); }
I want my player controlled object to come to sleep if it is moving to slow, so it doesn't keep rolling forever on slightly uneven terrain but as the sleepvelocity value was not having any effect I was afraid adding a force of 0 also prevented the rigidbody to go to sleep. So I tried above above test setup with also no effect.
So do I understand the use of rigidbody.sleepVelocity wrong, am I doing something wrong or is it broken?
Omg, thank you! (I'd upvote but I need more reputation. I've been searching for the answer to my problem for hours and your problem answered $$anonymous$$e by showing me sleepVelocity!!! Thank you so much!
Answer by Pete Roobol · Dec 10, 2010 at 05:47 PM
Just had the same problem, it kind of works- but value change of rigidbody.sleepVelocity has little effect, probably due to all the forces and other inter rb collisions jittering on (I have quite a few rbs)- update;
private bool AmISleepy(){
if (rigidbody.velocity.sqrMagnitude<1f && rigidbody.angularVelocity.sqrMagnitude<1f && pIAmTouching){
rigidbody.Sleep();
return (true);
}else{
return(false);
}
}
Your answer
Follow this Question
Related Questions
Get Rigidbodies to Sleep Faster 1 Answer
What does rigidbodies sleeping have to do with collision detection? 0 Answers
Rigidbody not sleeping 1 Answer
how do you tell if a rigidbody is awake 1 Answer
Why are my Rigidbodies not sleeping? 0 Answers