- Home /
Compound colliders, what is the best implementation?
Hi, I've been trying since a while to have a good system for a character's physic and collision detection.
First, what I am trying to achieve is to have a character that is composed of several parts (head, torso, left arm, right arm, left leg, right leg) Those parts can have individual collision detection, the character will have a damage amount based on the speed of impact on localized area, and if damage is high enough the part will detach from the rest. The whole character can fall or be moved as an individual object.
I tried several things only two approached me from my goal.
1 - I had a collider and rigidbody for the parent game object, the other parts had colliders , a rigidbody and a joint attached to the torso. This worked well except that I could not detect individual part's collisions in the code, OnCollisionEnter would only work for the parent game object. Though joints would break on impact which means the collision on children colliders did work, but I could just not intercept it in the code...
2- Then I changed to a rigidbody for the parent, no rigidbody for the children parts, but colliders for all the children parts individually. This again works well, I get the impact force on parts in OnCollisionEnter, except from the fact that it is very slow, on collision everything freezes for half a second... and if the parts detach I then need to had in runtime a rigidbody with gravity turned on to the children parts (if I do it before, the engine doesn't seem to like it)
So was any of the 2 ways starting well? What did I do wrong and what should I do to have it to run smoothly?
Thanks a lot for reading
Your answer
![](https://koobas.hobune.stream/wayback/20220613152244im_/https://answers.unity.com/themes/thub/images/avi.jpg)