Rigidbody.AddForce 添加力

function AddForce (force : Vector3, mode : ForceMode = ForceMode.Force) : void

Description描述

Adds a force to the rigidbody. As a result the rigidbody will start moving.

添加一个力到刚体。作为结果刚体将开始移动。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void FixedUpdate() {
		rigidbody.AddForce(Vector3.up * 10);
	}
}
// Adds a force upwards in the global coordinate system
//在全局坐标系统添加一个向上的力

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

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

Description描述

Adds a force to the rigidbody. As a result the rigidbody will start moving.

添加一个力到刚体。作为结果刚体将开始移动。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void FixedUpdate() {
		rigidbody.AddForce(0, 10, 0);
	}
}
// Adds a force upwards in the global coordinate system
//在全局坐标系统添加一个向上的力

function FixedUpdate () {
	rigidbody.AddForce (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