I need to know which collider shape I hit when a collision occurs. I do this using OnCollisionEnter/Stay, and it works well for normal rigidbodies (ie. a box, a sphere, etc.), but not for RB’s with composite colliders (ie. many collider shapes as children under a parent RB), The Collision object passed to my handler seems to have its ‘collider’ member set to the largest collider (or maybe just random) - not the one we actually hit. 'Sup with this?
The collider returned should be the one that was hit, not sure what could be the problem if it is not. However, when you have collided with something that has a rigidbody, you can use collision.rigidbody to see definitely what object you have hit. If you have multiple colliders under a single rigidbody, you can just use the rigidbody to identify the entire object.
If you are looking specifically for a collision between one of the several colliders on an object, then you’d have to identify the collider. You can use collision.collider, but it might also be worthwhile to check out the “contacts” array returned in a collision. This array holds all the ContactPoints for a collision, with each ContactPoint containing references to the colliders involved.
For example, collision.contacts[0].otherCollider. The only tricky thing is that I’ve noticed that “thisCollider” and “otherCollider” don’t seem to consistently refer to one object or the other, so you’ll need to do some testing.