Version: 2023.1

Rigidbody.GetRelativePointVelocity

切换到手册
public Vector3 GetRelativePointVelocity (Vector3 relativePoint);

描述

相对于点 relativePoint 处的刚体的速度。

计算速度时,GetRelativePointVelocity 会考虑到刚体的 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)); } }