Version: 2021.3

Physics2D.ClosestPoint

切换到手册
public static Vector2 ClosestPoint (Vector2 position, Collider2D collider);

参数

position The position from which to find the closest point on the specified Collider.
Collider 要在指定碰撞体上找到与之最接近的指定 position 的位置。

返回

Vector2 A point on the perimeter of the Collider that is closest to the specified position.

描述

Returns a point on the perimeter of the Collider that is closest to the specified position.

通过此函数能够计算指定 position 与任何 Collider2D 类型的周边最接近的点。

In the case where the position is inside the Collider or the Collider is disabled, then the input position is returned instead.


public static Vector2 ClosestPoint (Vector2 position, Rigidbody2D rigidbody);

参数

position 要在指定 rigidbody 上找到与之最接近的点的位置。
rigidbody 要在指定刚体上找到与之最接近的指定 position 的位置。

返回

Vector2 附加到 rigidbody 的碰撞体周边上最接近指定 position 的点。

描述

Returns a point on the perimeter of all enabled Colliders attached to the rigidbody that is closest to the specified position.

通过此函数能够计算指定 position 与附加到指定 Rigidbody2D 的任何已启用 Collider2D 类型周边最接近的点。

如果 position 处于附加到 rigidbody 的任何已启用 Collider2D 内部,则改为返回输入 /position/。

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961