# Why can't I rotate anything to be "more than 360 degrees or less than 0 degrees"?

I've been trying to make an animation in Unity, but most assets already come bundled with everything facing at 0 degrees, not to say it's a bad thing.

However, the problem I'm facing is that the animation keyframes aren't playing out correctly.
When this is done with raw measurements (simply dragging the XYZ rotations), negative and greater than 360 degree angles are taken account. But then again - Unity could be simply remapping them, whcih is not the case.

For example, the prop_robotArm prefab, found within Unity's Robot Factory asset pack has a rotator script that simply rotates the whole thing along the Y axis.

void OnFixedUpdate()
{
transform.Rotate (new Vector3(0, rotateSpeed*Time.deltaTime,0));
}


Meaning that after slightly more than a full revolution, the Y rotation value should be more than 360 degrees, which it does end up becoming... Eventually.

Thinking that was possible, I tried to mimic this behavior by making the arm rotate 720 degrees (twice) in an animation file (this is not using the rotator.cs script attached to the body in the example above).
Instead, all I ended up was the arm's body staying still as 720 is the same as... 0 degrees in rotation changes.

So, I tried a second experiment; trying to rotate from 359 degrees to 1 degree (or -1 to 1 degree).
Just like above, it didn't go to plan. When the animation is run, it simply runs from 359, through every angle in-between before reaching 1, instead of 359, 360 (0) and 361 (1).
If you don't get what I mean, see the diagram below.

## So, I was wondering, is there a way to allow for such rotation to be defined in an animation curve?

Every time I try doing it, any value greater than 360 (or lesser than 0) is replaced by its co-terminal counterpart that's between 0 and 359.999999...999.

• Unity is probably slerping the end rotations. Apr 14, 2015 at 15:08
• "...is replaced by its co-terminal counterpart that's between 0 and 359.999999...999" The words you may be looking for are "...is replaced by its coterminal angle on the range [0, 360)". You could also say "is mod 360d". Apr 14, 2015 at 21:10
• @ColeJohnson I can't just stay 360 since it's remapped to 0, where as 359.anything is still 359.something but 360.something is remapped to 0.something (It's read "where as 359-point-something is still 359-point-something but 360-point is remapped to 360-point-something) | It's like saying 10.0000... doesn't introduce a new decimal place, while 9.9999... still doesn't have a tens placing. Apr 15, 2015 at 4:08
• @aytimothy [0, 360) is a range. Braces means inclusive, and parenthesis means exclusive. So for a value x to be "on the range" [0, 360) means x >= 0 && x < 360. Notice how the 0 is greater than or equal to because it is a brace and the 360 is just less than because it is a parenthesis. So by saying "its coterminal angle on the range [0, 360)," you are saying the same thing, but more concisely. Apr 15, 2015 at 4:44

Unity supports two methods of animation interpolation:

• Quaternion interpolation (the default)
• Euler angle interpolation (what you're expecting)

Quaternion interpolation is smoother, but doesn't react gracefully to a single keyframe which rotates more than 180 degrees -- as you're seeing, it picks the shorter path, no matter what your intention was.

To quote from the Unity manual:

Quaternion interpolation cannot represent rotations larger than 180 degrees, because it is then shorter to go the other way around.

...

If rotations larger than 180 degrees are desired, additional keys must be placed in between.

You can either add more keyframes, or set each AnimationCurve to use Euler angle interpolation. Either option sounds a bit tedious, so it's up to you which is easier for your workflow.

In addition to what @rutter has mentioned, you can change animation view to "Curve" and adjust curves accordingly to achieve the smooth rotation

Probably I am little late, but I have the solution for this:

Add an offset of 360 to each Euler angle, now you do not want to apply it every time, so check if the rotation of the desired angle is lesser than 180 that is when you do not add an offset of 360, if it is not, add an offset of 360. @aytimothy