I am using Mathf.Atan2 to find angle in 2d and do not know how to apply relative rotation i want to achieve smooth rotation
Vector2 difference = anchorRotation- anchorRotationLastFrame;
float angle = Mathf.Atan2(difference.y, difference .x);
float angleInDegrees = angle * Mathf.Rad2Deg;
Vector3 rotate = new Vector3(turn, 0, angleInDegrees);
transform.localEulerAngles = rotate;//applying rotation
how to change this absolute rotations to relative ones? Like transform.Rotate
my object is in another rotating object and I am rotating it based on rotation of parent object
I want to achieve smooth rotation
Answer by Tortuap · Jan 30, 2018 at 11:13 AM
If you want to get rotations without jumps from one angle to another, don't directly set euler angles, but use quaternions. See Transform.rotation property and Quaternion.euler method.
In addition, in order to get smooth transition from a rotation to another, you'll have to lerp it over time. You could use a tweening library ( HotTween, GoTween, etc. ). Or do it yourself using Mathf.Lerp or in your case Quaternion.Lerp, with a timer you increment by Time.deltaTime in the Update method.
Your answer
Follow this Question
Related Questions
Why the values in the hierarchy and the values in the code are different ? 0 Answers
Struggling to get the rotation the player is moving in. 1 Answer
How to convert User Values into degree(Angle)?? 2 Answers
Rotate Sphere? 1 Answer
[VR] Make a bow follow the 'holding object' AND look at the 'string pulling hand' 1 Answer