- Home /
Question by
salevan3 · Mar 24, 2019 at 09:08 PM ·
c#rotationscripting problemquaternion
How do i make a smooth rotation using negative degrees?
Quaternions do not take negative values - that is the problem.. :^( And also i could have just used transform.rotate but i need my rotation to be smooth....
float rotationSpeed = 40F;
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(0, (-90), 0), rotationSpeed * Time.deltaTime);
Thank you in advance! And have a lovely day!
Comment
I am pretty sure Quaternion.Euler() does work with negative values. What doesn’t work in the code that you posted? Does it throw an error?
Answer by Glurth · Mar 24, 2019 at 10:09 PM
A Unity Quaternion defines an orientation, not an amount of rotation. (despite the name of the member "rotation", in Transform. It's just a poor name choice.) Therefore:
Quaternion.Euler(0, -90, 0);
is equivilent to
Quaternion.Euler(0, 360-90, 0)