Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

var localRotation: Quaternion;
Quaternion localRotation;
localRotation as Quaternion

Description

The rotation of the transform relative to the parent transform's rotation.

Unity stores rotations as Quaternions internally. To rotate an object, use Transform.Rotate. Use Transform.localEulerAngles for modifying the rotation as euler angles.

	// Set the rotation to be the same as the parent
	transform.localRotation = Quaternion.identity;
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Example() {
        transform.localRotation = Quaternion.identity;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Example() as void:
		transform.localRotation = Quaternion.identity