Download

Model-accurate hit detection

I’m working on implementing a combat system similar to Overgrowth, and I’m really debating with myself over how I want to configure hit detection. There are really only two specific things I need model-specific information for: 1) to simulate flinching/knockback local to the body part that got hit, 2) to calculate damage, either from impact (punches to the face hurt more than punches to the gut) or from falling (landing on your head hurts more than landing on your butt).

Each time the player attacks, I activate hurtboxes on their hands and feet which listen for collisions with enemy actors and notifies them on impact, a task that a single capsule collider roughly corresponding to their body is more than suitable for.

It seems like the simplest way to get model-accurate hit detection would be to place trigger volumes around the head, torso, limbs, and so forth, but that feels pretty hard-codey and would require me to manually configure hitboxes for each character, a task that becomes unwieldy as the cast grows, and downright problematic if I try to implement procedural character generation later on. Is there a cleaner way to get references to where the model has been hit?

If you want per-pixel, I’m not sure how.

If you want per-poly, I’m pretty sure I’ve seen support for via a variable or something, but I’ve never actually used it.

If you’re looking for accurate enough, the physics asset is your best bet.
You will need one of these for rag dolls, physics based animation, bbox calcing etc anyway.

Old answer hub post, but it should get you started:
https://answers.unrealengine.com/questions/842/how-would-i-get-what-part-of-a-skeletal-mesh-i-hit.html

For zone collision you could use a tri mesh and material id’s to identify a given zone. Simple implication of making a low poly version of a of the player model and included it as a component of the hero player model and turn off it’s visibility in game.

The tri mesh will be of single mesh design but masked using material id’s that you can apply a material sample designed to create the zone. On the legs for example it can be masked to a material called collision_legs and create a material collision.

Good way of doing it as there will never be any gaps in the collision.

Oh wow, the physics asset is exactly what I needed, thank you for the recommendation! I’d been mocking up an exceptionally crude version of that with colliders, but since I definitely need ragdolls anyway, this solves all of my problems in one go- thank you for the reading and the recommendation! :slight_smile: