I’ve been using a mesh collider on my enemies with raycasts to detect when the user clicks on them in order to trigger bullet hits. Now I’m at the point where I want to differentiate between a headshot, a bodyshot, and a legshot. Does anyone have any suggestions for how to go about doing this?
I’ve never tried it, but would compound colliders work? Each leg gets its own collider, the torso gets one, and the head gets one. That way, you can easliy determine where the person was hit by which collider is returned.
Maker16 is exactly right. Give each body part a collider and each collider a tag. You will then be able to tell what body part was hit on collision. A script like the following would be placed on the bullet.
function OnCollisionEnter (body : Collision) {
if (body.transform.tag == "head") {
Debug.Log("Head Shot!");
}
}