Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

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

Rigidbody.MoveRotation

Suggest a change

Success!

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

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public function MoveRotation(rot: Quaternion): void;
public void MoveRotation(Quaternion rot);
public def MoveRotation(rot as Quaternion) as void

Description

Rotates the rigidbody to rotation.

For kinematic rigidbodies it applies friction based on the motion of the rigidbody. This lets you simulate moving / rotating platforms with rigidbodies sitting on top of the elevator. If you want other rigidbodies to interact with the kinematic rigidbody you need to move it in the FixedUpdate function.

	var eulerAngleVelocity : Vector3 = Vector3 (0, 100, 0);
	function FixedUpdate () {
		var deltaRotation : Quaternion = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime);
		rigidbody.MoveRotation(rigidbody.rotation * deltaRotation);
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Vector3 eulerAngleVelocity = new Vector3(0, 100, 0);
    void FixedUpdate() {
        Quaternion deltaRotation = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime);
        rigidbody.MoveRotation(rigidbody.rotation * deltaRotation);
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public eulerAngleVelocity as Vector3 = Vector3(0, 100, 0)

	def FixedUpdate() as void:
		deltaRotation as Quaternion = Quaternion.Euler((eulerAngleVelocity * Time.deltaTime))
		rigidbody.MoveRotation((rigidbody.rotation * deltaRotation))