Can you have different collision box type with one gameobject.

I am doing a 2D game with Unity.

I have a character that is a plane with a collision box around. I tried to make it contain an empty object (drag and drop a gamobject on another one it appear inside, do not know how it is called) with another collision box.

But the new collision box trigger the OnCollisionEnter from the root gameobject. I wanted to be able to differentiate colission depending wich box was hit.

Is it possible to have collision elements triggereing different responses for the same logical object?

You could do something like this:

//added to child
function OnCollisionEnter(c : Collision)
{
    if (c.gameObject.transform == transform.parent) return;
    
    //rest of code
}

or

//added to parent
function OnCollisionEnter(c : Collision)
{
    if (c.gameObject.transform.parent == transform) return;
    
    //rest of code
}