Search Unity

2D intersection

Discussion in '2D' started by llamagod, Oct 23, 2016.

  1. llamagod

    llamagod

    Joined:
    Sep 27, 2015
    Posts:
    76
  2. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    I don't believe such a function exists for Collider2D. You could try using Bounds.ClosestPoint to do collider2D.bounds.ClosestPoint(otherPoint).
     
  3. llamagod

    llamagod

    Joined:
    Sep 27, 2015
    Posts:
    76
    I'm pretty sure that just clamps the point within the axis-aligned bounds. Doesn't help much if the gameobject the collider is attached to is rotated, or if the collider is not a BoxCollider2D. You could just do a boxcast towards the other collider, but the performance is terrible.