Rigidbody.AddTorque 添加力矩

function AddTorque (torque : Vector3, mode : ForceMode = ForceMode.Force) : void

Description描述

Adds a torque to the rigidbody.

添加一个力矩到刚体。

As a result the rigidbody will start spinning around the torque axis.

作为结果刚体将绕着torque轴旋转。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void FixedUpdate() {
		rigidbody.AddTorque(Vector3.up * 10);
	}
}
// Spins the rigidbody around the global y-axis
//旋转刚体绕世界y轴

function FixedUpdate () {
	rigidbody.AddTorque (Vector3.up * 10);
}

• function AddTorque (x : float, y : float, z : float, mode : ForceMode = ForceMode.Force) : void

Description描述

Adds a torque to the rigidbody.

添加一个力矩到刚体。

As a result the rigidbody will start spinning around the torque axis.

作为结果刚体将绕着torque轴旋转。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void FixedUpdate() {
		rigidbody.AddTorque(0, 10, 0);
	}
}
// Spins the rigidbody around the global y-axis
//旋转刚体绕世界y轴

function FixedUpdate () {
	rigidbody.AddTorque (0, 10, 0);
}

If you want to apply a force over several frames you should apply it inside FixedUpdate instead of Update.

如果你想在多帧中应用力,你应该在FixedUpdate中而不是Update使用使用它。

Page last updated: 2011-2-9