struct in UnityEngine
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.Close
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.Close
Quaternions are used to represent rotations.
They are compact, don't suffer from gimbal lock and can easily be interpolated.
Unity internally uses Quaternions to represent all rotations.
They are based on complex numbers and are not easy to understand intuitively. You almost never access or modify individual Quaternion components (x,y,z,w); most often you would just take existing rotations (e.g. from the Transform) and use them to construct new rotations (e.g. to smoothly interpolate between two rotations). The Quaternion functions that you use 99% of the time are: Quaternion.LookRotation, Quaternion.Angle, Quaternion.Euler, Quaternion.Slerp, Quaternion.FromToRotation, and Quaternion.identity. (The other functions are only for exotic uses.)
You can use the Quaternion.operator * to rotate one rotation by another, or to rotate a vector by a rotation.
Note that Unity expects Quaternions to be normalized.
|identity||The identity rotation (Read Only).|
|eulerAngles||Returns or sets the euler angle representation of the rotation.|
|normalized||Returns this quaternion with a magnitude of 1 (Read Only).|
|this[int]||Access the x, y, z, w components using , , ,  respectively.|
|w||W component of the Quaternion. Do not directly modify quaternions.|
|x||X component of the Quaternion. Don't modify this directly unless you know quaternions inside out.|
|y||Y component of the Quaternion. Don't modify this directly unless you know quaternions inside out.|
|z||Z component of the Quaternion. Don't modify this directly unless you know quaternions inside out.|
|Quaternion||Constructs new Quaternion with given x,y,z,w components.|
|Set||Set x, y, z and w components of an existing Quaternion.|
|SetFromToRotation||Creates a rotation which rotates from fromDirection to toDirection.|
|SetLookRotation||Creates a rotation with the specified forward and upwards directions.|
|ToAngleAxis||Converts a rotation to angle-axis representation (angles in degrees).|
|ToString||Returns a nicely formatted string of the Quaternion.|
|Angle||Returns the angle in degrees between two rotations a and b.|
|AngleAxis||Creates a rotation which rotates angle degrees around axis.|
|Dot||The dot product between two rotations.|
|Euler||Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis; applied in that order.|
|FromToRotation||Creates a rotation which rotates from fromDirection to toDirection.|
|Inverse||Returns the Inverse of rotation.|
|Lerp||Interpolates between a and b by t and normalizes the result afterwards. The parameter t is clamped to the range [0, 1].|
|LerpUnclamped||Interpolates between a and b by t and normalizes the result afterwards. The parameter t is not clamped.|
|LookRotation||Creates a rotation with the specified forward and upwards directions.|
|Normalize||Converts this quaternion to one with the same orientation but with a magnitude of 1.|
|RotateTowards||Rotates a rotation from towards to.|
|Slerp||Spherically interpolates between a and b by t. The parameter t is clamped to the range [0, 1].|
|SlerpUnclamped||Spherically interpolates between a and b by t. The parameter t is not clamped.|
Did you find this page useful? Please give it a rating: