Compound collider object behaving as a whole?

Hi,

Is there any possiblity for a Compound collider object to just fire an event to the parent rigidbody object?

I have a compound object made of 2 1x1 cubes (one beside the other). This 2 cubes are set as triggers and have a parent that have a rigidbody. On the other hand I have a 1x1 cube with a rigidbody attached. When I make the 1x1 cube touch the compound object (And it is touching the 2 blocks that build it up) I get two calls to OnTriggerEnter(). Is there any way to make the compound object behave as a whole without using a mesh collider?

P.D. The compound objects may have differnt shapes made of blocks, so, I really need to add more than one colliders to create the final physical shape. I won’t be able to just merge the colliders and resize one to cover them all.

Cheers.

No, not that i know. They are still seperate colliders and they will detect collisions with their surface. If both collide / intersect with another collider they will both trigger an event. For what kind of functionality do you need those triggers? You could use a Dictionary to count how many times a collider is currently touching your compound trigger:

using System.Collections.Generic;

// ...
Dictionary<Collider, int> m_Colliders = new Dictionary<Collider, int>();

void OnTriggerEnter(Collider aOther)
{
    if (m_Colliders.ContainsKey(aOther))
    {
        m_Colliders[aOther]++;
        SendMessage("OnCompoundTriggerEnter", aOther, SendMessageOptions.DontRequireReceiver);
    }
    else
        m_Colliders.Add(aOther, 1);
}

void OnTriggerExit(Collider aOther)
{
    if (m_Colliders.ContainsKey(aOther))
    {
        m_Colliders[aOther]--;
        if (m_Colliders[aOther] <= 0)
        {
            m_Colliders.Remove(aOther);
            SendMessage("OnCompoundTriggerExit", aOther, SendMessageOptions.DontRequireReceiver);
        }
    }
    else
        Debug.LogError("This should never happen");
}

This will invoke the method “OnCompoundTriggerEnter” when a collider enters one of the triggers for the first time and any additional will be ignored. When the collider exits the last trigger OnCompoundTriggerExit will be called. So those messages would behave the way you wanted. However it wouldn’t work between two compound triggers.

For future questions i helps to get more information about why you need this funcionality. In many cases there are easy workarounds but without knowing what you actually want to achieve we can’t suggest a solution.