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);
}
最后修改:2011年2月10日 Thursday 20:09

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。