- Home /
turn of the object behind the auxiliary quaternion lerp
how can I, when I press a key, rotate an object that has a rigidbody component, let's say 30 degrees along the X axis, beyond the quaternion lerp, I can’t find the documentation
Answer by lgarczyn · Jan 23, 2020 at 03:46 AM
I'm not quite sure what you mean by "behind the auxiliary quaternion lerp" and "beyond the quaternion lerp", but if your rigidbody is kinematic, you should do this, which allows for interpolation
rigibody.MoveRotation(Quaternion.AngleAxis(30, Vector3.right) * rigidbody.rotation);
For a dynamic rigidbody, kinematic interpolation is impossible, you can have an instant rotation like this, which is equivalent to the previous line, but makes your intent clear
rigibody.rotation = Quaternion.AngleAxis(30, Vector3.right) * rigidbody.rotation;
If you want a smooth transition with a dynamic rigidbody, you need this
rigidbody.angularVelocity = new Vector3(30 / rotationDurationInSeconds, 0f, 0f);
and stop the rotation after the rotation time.
Yes, it’s kind of what I need, but can I rotate using these lines so that it rotates the radius by definition, that is, it rotates the object 30 degrees and quietly,? ,
These all rotate 30 degrees, except the velocity one, which has to be stopped one it reaches the target rotation. You can change the 30f in every line to change the amount of rotation.
Your answer
Follow this Question
Related Questions
object rotation with rigidbody component 1 Answer
Keeping relative rotation to another object 0 Answers
Rotate an object to a given point 2 Answers
Rigidbody goes wonky after collision 0 Answers