Question by
Chickenator · Dec 27, 2015 at 09:06 PM ·
c#rotationrigidbody
Make rigidbody rotate smoothly back to original position if flipped?
In C# how would you make a rigidbody automatically right itself if rotated smoothly? I think you use Rigidbody.MoveRotation but I'm not exactly sure on how to use it the way I want to. Any help?
Comment
Answer by Gnorpelzwerg · Dec 28, 2015 at 11:01 AM
Try this
Quaternion desiredRotation;
float speed; //in degrees
Rigidbody rigidbody;
void Update( ) {
rigidbody.MoveRotation( Quaternion.RotateTowards( rigidbody.rotation, desiredRotation, speed * Time.deltaTime );
}