Enforcing clockwise direction for Quaternion.RotateTowards()
Hi,
Searched a bit but did not find the answer. Can anyone more experienced please help ??
I'm using the standard Unity public static Quaternion.RotateTowards(Quaternion from, Quaternion to, float maxDegreesDelta);
method. Let's say I'm rotating around the Y axis. I want the object to always rotate clockwise from 0 - 270 degrees (long rotation). How to achieve this ?
Currently when the to
angle is less than 180 degrees then the object rotates clockwise. When it is greater than 180 degrees then the object takes shorter rotation and rotates counterclockwise (for 270 it rotates to -45 degrees).
Please help. Thank you.
The purpose of RotateTowards is to always take the shortest angle. For "clockwise" it might be easier to not use it. Or, and this is common, are you sure you need clockwise? $$anonymous$$aybe shortest angle is better?
If you only want to spin around Y, simple enough to record your own Y degrees and manually increase it. For other funny facings, angleAxis around a cross-product plus getting Angle, then manually increasing from 0 to the final value should work (a ton of work if you don't know how to use those.)
Or, one hack is to provide a "way point." If the angle is negative, force clockwise by running RotateTowards on something 90 degrees to your right.
Thanks.
The next step was to do the endless rotation basing on the RotateTowards method. I think I'll go with manually increasing the angle say with use of target angle % 180. This will address both.