identity
The identity rotation (Read Only).
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public static Quaternion identity { get; }
Remarks
This property represents zero rotation. For example, if you assign to a transform's world rotation, the transform's axis (right, up, forward) aligns with the world axis (x, y, z). If you assign it to the transform's local rotation, the transform aligns with the axis of its parent.
Quaternion.identityKey property characteristics:
- Setting aligns the object with the world axes.
transform.rotation = Quaternion.identity - Setting sets the object's local rotation to match the parent's orientation (no local rotation relative to the parent).
transform.localRotation = Quaternion.identity - Multiplying by has no effect.
Quaternion.identity
Common use cases:
- Instantiate objects with neutral rotation: .
Instantiate(prefab, position, Quaternion.identity) - Reset object rotation to world-aligned state.
- Use as a starting point for rotational calculations.
Examples
using UnityEngine;public class QuaternionIdentityExample : MonoBehaviour{ public Transform parentObject; public Transform childObject; void Start() { // Quaternion.identity represents zero rotation relative to world coordinate system, aligned with world axes. transform.rotation = Quaternion.identity; // Demonstrate the difference between world rotation and local rotation: if (parentObject != null && childObject != null) { // Set child to identity rotation childObject.rotation = Quaternion.identity; // Child is aligned with world axes, not current parent's rotated axes. Debug.Log($"Child rotation: {childObject.rotation}"); Debug.Log($"Parent rotation: {parentObject.rotation}"); // To align with current parent axes, use: // childObject.localRotation = Quaternion.identity; } }}