Version: 2020.2

Rigidbody.GetPointVelocity

切换到手册
public Vector3 GetPointVelocity (Vector3 worldPoint);

描述

点 /worldPoint/(全局空间)处刚体的速度。

计算速度时,GetPointVelocity 会考虑到刚体的 angularVelocity。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Rigidbody rb;

void Start() { rb = GetComponent<Rigidbody>(); }

// Get the velocity of a wheel, specified by its // position in local space. Vector3 CalcWheelVelocity(Vector3 localWheelPos) { return rb.GetPointVelocity(transform.TransformPoint(localWheelPos)); } }