Version: 2018.2
public static ColliderDistance2D Distance (Collider2D colliderA, Collider2D colliderB);

Parameters

colliderAA collider used to calculate the minimum distance against colliderB.
colliderBA collider used to calculate the minimum distance against colliderA.

Returns

ColliderDistance2D The minimum distance between colliderA and colliderB.

Description

Calculates the minimum distance between two colliders.

A valid colliderA and colliderB must be provided for the returned ColliderDistance2D to be valid i.e. both colliderA or colliderB should not be NULL, should not be disabled and must contain collision shapes. You can check if the returned value is valid by checking ColliderDistance2D.isValid.

See Also: Collider2D.Distance and Rigidbody2D.Distance.

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