Rigidbody.MoveRotation 移动旋转

function MoveRotation (rot : Quaternion) : void

Description描述

Rotates the rigidbody to rotation.

旋转刚体到rot。

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.

对于运动学刚体,它基于刚体的运动应用摩擦力。这个让你模拟刚体位于移动/旋转平台之上的情况。如果你想其他的刚体与运动学刚体交互,你需要在FixedUpdate函数中移动它。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Vector3 eulerAngleVelocity = new Vector3(0, 100, 0);
	void FixedUpdate() {
		Quaternion deltaRotation = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime);
		rigidbody.MoveRotation(rigidbody.rotation * deltaRotation);
	}
}
var eulerAngleVelocity : Vector3 = Vector3 (0, 100, 0);
function FixedUpdate () {
	var deltaRotation : Quaternion = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime);
	rigidbody.MoveRotation(rigidbody.rotation * deltaRotation);
}
Page last updated: 2011-2-10