2
\$\begingroup\$

Say you have a character standing behind cover such that some of its body parts like a shoe or a palm is still outside the cover.

An explosion takes place close to the cover . In real life this would mean the player getting damage in his arm or whichever body part was outside the cover.

How would you simulate this kind of hit detection efficiently in a game ?

An approximation would be to line trace from center of the explosion to each bone in the character mesh. But it might still not be accurate enough for larger bones , would be performance intensive and would not work for objects which are not skeletal meshes.

\$\endgroup\$
  • \$\begingroup\$ May be computationally expensive, but you could step into the models vertices and test for each collision against the explosion Frustum. Count the number of vertices affected, and create a formula that inflicts damage based on a percent * number of vertices. \$\endgroup\$ – Krythic Nov 11 '16 at 14:24
  • \$\begingroup\$ Or just test if they are in cover and inflict a base damage by percent. So if they are in cover the player/entity will receive 75% damage mitigation from explosions. They're essentially buffed while in cover. \$\endgroup\$ – Krythic Nov 11 '16 at 14:28
2
\$\begingroup\$

A rather cheap but sufficiently accurate method is to mark key points on the character, in a tree structure such as one on the tip of the finger, one on the hand, one on the elbow, one on the shoulder as one branch etc. Note that elbow and shoulders are important points as those parts also have a chance to be exposed while the remaining body/arm is not. If there is room for more calculation you can also add a point for each section of the arm for more accurate damage calculation.

For the leg something like tip of feet, ankle, knee, hip would give a fairly accurate result. You can place the point for hip towards the end of the butt for more accuracy as I am sure no normal animation will make a character trust his/her hip forward out of cover. For the head it is probably as many points as you can but on normal animations, placing one on the forehead and one on the top of the head will cover most possible exposed areas.

To calculate the amount of damage received, you can trace the center of explosion to highest point of that branch or calculate how many points on the branch that is hit and apply a pre-determined multiplier. Or if your game has a body part damage system, damage that part of the body.

I do not suggest calculating by bones as there are usually more in certain places like the hand - each fingers will consist of at least 2 for animation, which there is almost no chance that a single finger is exposed to the explosion while the remaining are completely in cover - unless your character has a weird fetish of sticking his pinky out of cover to test for heat.

\$\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.