Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


distance

Gets the distance between two colliders.
Read time 1 minuteLast updated 4 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 _pointA and _pointB. The _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.