My gameobject is a parent with a rigidbody and children containing colliders. This Object (compound collider) should trigger only once per entering/re-entering the trigger. The standard behaviour on this is that for each child collider in the compound collider a trigger event is fired, actually this makes sense. But, is there any smart way to limit it to the compound collider firing only once per entering/re-entering the trigger and not for each child? In my situation it would be nice to have it fire only once per trigger enter.
Currently I have this code running, it improves the situation but it is not reliable enough:
private var collisionTimeDelta : float = .2;
private var collisionTime : float = 0;
function OnTriggerEnter (collider : Collider)
{
if (Time.time > collisionTime)
{
collisionTime = Time.time + collisionTimeDelta;
if(collider.gameObject.tag == "myCollider")
{
DoSomething();
}
}
}