Determine Reflection off of Edge Collider collision

Is there a way to get the closes point of a edge collider from a collision? I was thinking for the scenario depicted in the image, that if the ball hits the horizontal part of the edge collider, that I could get the two nearest points to see if the collider is horizontal and then reflect the ball based on the y axis. And vice versa check if the ball hits the vertical side that the ball reflects in the x axis.

I’ve already had a solution using two different colliders to defferientiate the two sides, but in further implementations it creates complications.

If anyone knows how to determine which way to reflect the ball base on the part of the edge collider it impacts, that’d be much appreciated.

alt text
I’m using an OnCollisionEnter2d on the ball object. The edge collider is being accessed through the variable Collision2D collision.

Collision info is stored in a ContactPoint2D variable for every point of contact. As part of this, you can access the normal, which is a Vector2 in the direction the surface is facing. You can use that to reflect the ball’s velocity.

void OnCollisionEnter2D (Collision2D collision)
{
    ball.velocity = Vector2.Reflect (ball.velocity, collision.GetContact (0).normal);
}