Collision2D.GetContact not returning correct position?

Those contacts come from Box2D but they are the locations of where the physics engine will apply a force to keep things separated. They are not guaranteed to be specific surface intersection points as they are not for that. They can be inside one of the colliders for instance.

That said, they follow a fairly simply pattern so two intersecting boxes would be on the surfaces of those boxes.

Note that you can go into “Project Settings > Physics 2D > Gizmos > Show Collider Contacts” to see the contact points and arrows indicating the contact normals. This’ll save you having to draw them yourself using instantiated objects. See here (scroll down to “Gizmos”). It’s not clear if that arrow in your image is this, maybe so.

Also note, you should use Quaternion.identity to indicate no rotation.

I’d be interested in seeing the set-up above as a simple project if you have it?

NOTE: I would ask that you always post code using code-tags as it makes things much easier to read.

Thanks!

1 Like