Is this a correct way to have multiple different compound colliders in one gameobject?

Hi,

I’m currently trying to make a gameobject that has multiple colliders and I want different action to be performed depending on which collider was triggered. However, due to compound collider listening to every collider in children, I was having difficulty making it work as I wanted. So I came up with this solution and I was wondering if this is proper way to do this. Basically, I gave rigid bodies to the child object as well as the root parent object and then connected the child rigid bodies to parent using fixed joint. Each child object will have their own children with colliders attached to it resulting in multiple different compound colliders in one gameobject.

alt text

alt text

alt text

Would this setup work as I’m hoping or will there be any negative consequence that I am missing? I’ve made mass of parent very high and mass of child rigid bodies low so the movement happening on parent object won’t be affected by child’s physics. My main worry is having multiple rigid bodies on same gameobject as I heard it can sometimes cause physics to behave unpredictably.

@robocup30

If you can switch to OnTriggerEnter you could just make your child colliders have kinematic rigidbodies. You will get the events and you don’t have to worry about hooking everything up with fixed joints or having your colliders get knocked out of joint.

What kind of objects are expected to be colliding with the child objects? Is this for combat, movement, both? Something else?

Depending on your use case it might actually be more straightforward to have the collision script and the rigidbody on the other objects (those not part of the hierarchy you mentioned). That way you know exactly which objects are hit. You could then use SendMessageUpwards to send the event to the parent object (or if performance is a special concern using a standard C# event or a UnityEvent might be an option).