Rigidbody.GetPointVelocity 获取点速度

function GetPointVelocity (worldPoint : Vector3) : Vector3

Description描述

The velocity of the rigidbody at the point worldPoint in global space.

刚体在世界坐标空间中worldPoint点的速度。

GetPointVelocity will take the angularVelocity of the rigidbody into account when calculating the velocity.

GetPointVelocity在计算速度的时候将考虑刚体的角速度angularVelocity。
using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Vector3 point;
	public Vector3 velocity;
	public void Awake() {
		point = transform.InverseTransformPoint(new Vector3(0, -0.2F, 0));
		velocity = rigidbody.GetPointVelocity(point);
		print(velocity.magnitude);
	}
}
// Prints the velocity of the wheel
//打印车轮的速度

var point : Vector3;
var velocity : Vector3;
point = transform.InverseTransformPoint(Vector3(0, -.2, 0));
velocity = rigidbody.GetPointVelocity(point);
print(velocity.magnitude);
最后修改:2011年2月10日 Thursday 19:59

本脚本参考基于Unity 3.4.1f5

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