- Home /
FromToRotation - Smoothly!
I'm trying to use transform.rotation = Quaternion.FromToRotation(currentRot, Vector3(270,0,0)); in order to rotate a fighter jet back to it's normal orientation. This does work, but it snaps back. Is there any way to get this rotation working smoothly, so it eases back to the 'zero' posistion once a player releases a key?
Answer by luizgpa · Feb 09, 2012 at 05:37 PM
You could use Quaternion.RotateTowards() to interpolate to the desired rotation. Eg:
//Get target rotation
if(Input.GetKeyUp(KeyCode.Space))
targetRotation = Quaternion.FromToRotation(currentRot, Vector3(270,0,0);
...
//Rotate towrds target
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, angularSpeed);
Your answer
Follow this Question
Related Questions
Create a straight gradient equation with a grid of 3d objects 1 Answer
Transform.Rotate irrespective of local rotation? 1 Answer
My object isn't rotating to the transform of another object. How do I fix this? 1 Answer
object rotates when moving backward 1 Answer
Pixel values of a plane (RectTransform)? 0 Answers