Search Unity

Is there an approximation used for ClosestPoint() on polygon Collider2D?

Discussion in 'Getting Started' started by Deleted User, Aug 26, 2019.

  1. Deleted User

    Deleted User

    Guest

    I'm using a polygon collider for the rocket in my lander clone and I wanted to use ClosestPoint() on the collider to find the closest point to the velocity vector ( normalized and multiplied by rocket height to ensure it's outside the collider )

    The issue is that when I draw debug lines I see that the line from the rocket midpoint to the closest point on the collider always appears to extend beyond the rocket slightly which has me worrying that my collision logic won't work.

    Is this just a side-effect of the Debug.Drawline or can someone clue me in as to what's going on? The magenta line is my line from rocket center to the closest collider point to the direction of travel ( I know that this will give bad results for collisions this was just a proof of concept, the actual implementation will run from the collision point to the rocket )