Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


separation

Gets the distance between the colliders at the contact point.
Read time 1 minuteLast updated 6 days ago

Definition

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

Remarks

Unity's physics engine tracks the distances between all potentially overlapping colliders. Once a given collider pair has overlapped (collided), contacts are immediately generated and an OnCollisionEnter2D event is sent. While the collider pair is still active, the distance between the colliders can be greater than zero, equal to zero, or even less than zero when the colliders are still apart, touching, or overlapping respectively.