The identity rotation (Read Only).
This property represents zero rotation. For example, if you assign Quaternion.identity 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.
Key property characteristics:
transform.rotation = Quaternion.identity aligns the object with the world axes.transform.localRotation = Quaternion.identity sets the object's local rotation to match the parent's orientation (no local rotation relative to the parent).Quaternion.identity has no effect.Common use cases:
Instantiate(prefab, position, Quaternion.identity).
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; } } }