Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


distance

Gets the distance between two colliders.
Read time 1 minuteLast updated 10 days ago

Definition

  • Type: Property
  • Namespace: UnityEngine
  • Assembly: UnityEngine.Physics2DModule
public float distance { get; set; }

Remarks

The distance between two colliders is defined as the length of a Vector2 between ColliderDistance2D.pointA and ColliderDistance2D.pointB. The ColliderDistance2D.distance between these points can be positive indicating that the Collider2D are separated (not overlapped), zero indicating that they are touching (but not overlapped) or negative indicating that they are overlapped.