Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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,802
    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.