- Home /
Question by
toishaanpatel · Jun 18, 2020 at 02:45 PM ·
rotateeuleranglesnegative
Is it possible to lerp to a negative euler angle?
I despirately need to use the lerp function to rotate towards a negative value on one axis, but euler angles will not let me do that. Is there any way to rotate towards a negative axis in euler angles?
Comment
You can construct Quaternions using euler angles (even negative ones) and lerp between them. Have you tried using Quaternion.Euler and Quaternion.Lerp?
Answer by Ybs · Oct 09, 2020 at 11:16 AM
You can use Quaternions.
t += Time.deltaTime;
transform.rotation = Quaternion.Lerp(transform.rotation, new Quaternion (endRotation), t);
You can find the desired endRotation quaternion in the inspector. Rotate the object to the desired end rotation and right-click on the inspector, click Debug. Now you can see the corresponding quaternion. (for example x=0, y=0.7, z=0.7, w=0). Substitute endRotation with this value.
Your answer
![](https://koobas.hobune.stream/wayback/20220613001240im_/https://answers.unity.com/themes/thub/images/avi.jpg)