0
\$\begingroup\$

I have been using unity game engine for about two weeks now. And I'm very interested in 3D game development. I have been learning basics of Unity and third person games. I saw many tutorials about creating a 3D third person player. They just drag the character into unity and create a capsule collider around the character and freeze the rotation around x and z axis.

So my question is: is it possible to add different colliders to each body part of the character and if so how do I do accomplish that?

\$\endgroup\$
  • 2
    \$\begingroup\$ Did you try grabbing a body part of your character (say, one of the bone transforms of its skeleton) and attaching a collider to it using the normal Add Component workflow? What happened when you did this? Did you get the expected result, or did the behaviour differ from what you wanted in some particular way? \$\endgroup\$ – DMGregory Apr 8 at 16:58
  • \$\begingroup\$ Yeah, I saw the same answer in unity forum. But the thing is I downloaded the character from mixamo.com (Because I don't know anything about 3d modeling, that's why I cant make my own character). Anyway there's no way to select just a body part but all. \$\endgroup\$ – Buddhima Z Apr 8 at 17:15
  • 1
    \$\begingroup\$ Show us what you're seeing in the Unity hierarchy and scene view so we can help you with that problem. \$\endgroup\$ – DMGregory Apr 8 at 17:41
  • \$\begingroup\$ The technique you're describing is called "Compound colliders" in case you want to google it. The official docs have a section on them here: docs.unity3d.com/Manual/class-Rigidbody.html \$\endgroup\$ – Yeats Apr 8 at 18:49
1
\$\begingroup\$

It's entirely possible. Preferably you just attach them to the game object representing that part of the body. If your mesh didn't import into different game objects then you should look into how to do that with import settings, as the alternative is to make gameobjects that are invisible with the colliders you want, then animate them with your model to match. But that is VERY tedious.

It's also important to know that a parent rigidbody acts like a vacuum for collision messages. Any colliders will belong to the nearest parent rigidbody, and work together as such. Make sure you have a rigidbody on your character, and the colliders are on child gameobjects of that rigidbody. They will also however collide with eachother, so you should put them on a collision layer and use the Collision Matrix to make them avoid self collision.

Lastly, the reason we use a capsule collider is because it avoids a lot of edge cases to simplify our collision geometry. A common thing to do is seperate our physical body collier from our damage/hitbox. Our physical collider should be simple, round, and aproximate. Thus a capsule collider is perfect. However for say, first person shooters, we want precise boundaries for bullet detection. Here we can go and add a seperate set of colliders, and again put them on a layer that only colliders with things that damage it. These colliders are more precise but don't handle physics, merely collision / hit detection. You should probably even make them triggers.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.