Version: 2020.2
Scale Constraint

Unity の回転と向き

Rotations in 3D applications are usually represented in one of two ways: Quaternions or Euler angles. Each has its own uses and drawbacks. Unity uses Quaternions internally, but shows values of the equivalent Euler angles in the Inspector to make it easy for you to edit.

Euler angles and quaternions

Euler angles

Euler angles are represented by three angle values for X, Y and Z that are applied sequentially. To apply an Euler rotation to a particular GameObject, each rotation value is applied in turn, as a rotation around its corresponding axis.

  • 利点 - オイラー角は、3つの角度から構成される直感的で「人間が理解できる」フォーマットで表現されています。
  • 利点 - オイラー角は、180度以上の回転を経て、1つの向きから別の向きへの回転を表現できます。
  • 制限 - オイラー角はジンバルロック (Gimbal lock) として知られている制限があります。対象をそれぞれの軸に沿って順に回転させるとき、第一、第二の回転によって、結果的に 3つ目の軸にそろってしまうことがあります。つまり、第三の回転値を 3つ目の軸に反映できないために、「角度の自由」が失われてしまいます。


Quaternions can be used to represent the orientation or rotation of a GameObject. This representation internally consists of four numbers (referenced in Unity as x, y, z & w) however these numbers don’t represent angles or axes and you never normally need to access them directly. Unless you are particularly interested in delving into the mathematics of Quaternions, you only really need to know that a Quaternion represents a rotation in 3D space and you never normally need to know or modify the x, y & z properties.

In the same way that a Vector can represent either a position or a direction (where the direction is measured from the origin), a Quaternion can represent either an orientation or a rotation - where the rotation is measured from the rotational “origin” or “Identity”. It is because the rotation is measured in this way - from one orientation to another - that a quaternion can’t represent a rotation beyond 180 degrees.

  • 利点 - クォータ二オンの回転は、ジンバルロックの影響を受けません。
  • 制限 - 単体のクォータ二オンでは、180度を超す回転を表すことができません。
  • 制限 - クォータ二オンの数的表現は、直感的に理解できません。

Unity stores all GameObject rotations internally as Quaternions, because the benefits outweigh the limitations.

The Transform Inspector displays the rotation using Euler angles, because this is easier to understand and edit. Unity converts new values into the Inspector for the rotation of a GameObject into a new Quaternion rotation value for the GameObject.

The rotation of a GameObject is displayed and edited as Euler angles in the Inspector, but is stored internally as a Quaternion
The rotation of a GameObject is displayed and edited as Euler angles in the Inspector, but is stored internally as a Quaternion

As a side-effect, it is possible in the Inspector to enter a value of, say, X: 0, Y: 365, Z: 0 for a GameObject’s rotation. This value is not possible to represent as a quaternion, so when you enter Play mode, the GameObject’s rotation values change to X: 0, Y: 5, Z: 0. This is because Unity converts rotation to a Quaternion which does not have the concept of a full 360-degree rotation plus 5 degrees, and instead is set to orient the same way as the result of the rotation.

To learn more about scripting with the Quaternion class, see the Quaternion User Manual page and the Quaternion Scripting Reference

Implications for Animation

Many 3D authoring packages, and Unity’s own internal Animation window, allow you to use Euler angles to specify rotations during an animation.

These rotations values can frequently exceed ranges expressable by quaternions. For example, if a GameObject rotates 720 degrees, this could be represented by Euler angles X: 0, Y: 720, Z:0. But this is not representable by a Quaternion value.

Unity’s Animation Window

Within Unity’s own animation window, there are options which allow you to specify how the rotation should be interpolated - using Quaternion or Euler interpolation. By specifying Euler interpolation you are telling Unity that you want the full range of motion specified by the angles. With Quaternion rotation however, you are saying you simply want the rotation to end at a particular orientation, and Unity uses Quaternion interpolation and rotate across the shortest distance to get there. See Using Animation Curves for more information on this.

External Animation Sources

アニメーションを外部ソースからインポートする場合、これらのファイルは、通常はオイラー形式の回転キーフレームアニメーションを含んでいます。Unity のデフォルトのビヘイビアでは、これらのアニメーションをリサンプルして、各フレームごとに新しくクォータニオンキーフレームを生成し、キーフレーム間の回転がクォータニオンの有効範囲を超える状況をすべて回避しようとします。

For example, imagine two keyframes, 6 frames apart, with values for X as 0 on the first keyframe and 270 on the second keyframe. Without resampling, a quaternion interpolation between these two keyframes would rotate 90 degrees in the opposite direction, because that is the shortest way to get from the first orientation to the second orientation. However by resampling and adding a keyframe on every frame, there are now only 45 degrees between keyframes so the rotation works correctly.

リサンプリングを行っても、インポートしたアニメーションのクォータニオン表示がオリジナルに十分近い値にならない場合があります。このため、Unity 5.3 以降では、アニメーションリサンプリングをオフにするオプションがあります。これを使うと、代わりに、ランタイムにオイラーアニメーションキーフレームを使用します。詳しい情報は、Animation Import of Euler Curve Rotations を参照してください。

Scale Constraint