Get both colliders involved in a collision

Hello 2D mens, Im looking into the 2d physics & have noticed that collision info returned is a little different in the box2d than the 3d physics.

Unity - Scripting API: Collision2D describes how you get all the contact information on the ‘incomming’ collider but you dont get any info on the ‘local’ collider that hit the incomming collider. With the 3d system you get both colliders involved in the collision (referenced as ‘thiscollider’ & ‘othercollider’).

My setup has compound colliders & i need to know which one of those colliders was hit - any ideas how I go about finding that out? (without putting a behaviour on every collider please).

Can’t You just use line like below?

gameObject.GetComponent<Collider2d>();

Then You will get local collider.

hi codeedward thanks for jumping in. I think i got this resolved :

In this case my collision listener is higher up the hierarchy from my compound colliders so i need to find out which one them was involved in the collision from the incomming Collision2d.contacts.

In the 3d system i could get that data from Collision.contacts[×].thisCollider but in the 2d system there is no ‘thisCollider’ in Collision2d.contacts.

However i am now getting the data i need, and it seems to be reversed in the 2d system - i get my reference to my local compound collider from Collision2d.contacts[×].otherCollider and the incomming collider is referenced from Collision2d.contacts[×].collider.

At least that seems to be whats going on…probably dosent make much difference unless your converting 2d physics to 3d or vise versa where its a nice little man trap.