- Home /
Scripting Multiple Colliders per Object
Lets say I had a human mesh, and I wanted a box collider on his head, arms, legs, and his torso, would it be possible to put all 4 colliders on the same mesh, or would I have to make each arm, leg, torso, and head a separate mesh and have a collider for each one. If the former is possible, is it possible that a script can see which collider is colliding with an object?
if your character is rigged then you should be able to put the colliers on the joints.
Check here: http://docs.unity3d.com/Documentation/ScriptReference/Collider.html look at messages sent
Answer by ccontinisio · Nov 24, 2012 at 09:27 PM
You should find a way to "traverse" the body structure and find all the colliders, and maybe act on each one depending on his name. Something like:
foreach(Collider jointCollider in theBody.GetComponentsInChildren<Collider>())
{
//Put your code here
}
This way, you will iterate in all the Collider objects in the GameObject called theBody.