Just more of a concept question. If a character uses a capsule collider for it’s main collision needs, and have a nested 3d model with ragdoll setup (disabled while ingame, to be enabled when dead), how to check if this character received a bullet-head collision?
You’d probably need something like “bullets”, “level geometry”, “navigation collider” and “body collider”.
In this case, “bullets” could collide with “level geometry” and “body collider” while “navigation collider” would collide with “level geometry” (and other “navigation colliders”). LEvel colliders would be “level geometry”, player capsule would be “navigation collider”, projectiles would be “bullets” and ragdoll colliders would be “body collider”.
I read your question slightly different than @neginfinity . If the ragdoll is not on until hit the head collider won’t be there. In that case you can get the hit data from the capsule collision. First compare the y position of the hit to the head bone positions. If outside the limits return. If inside the limits then extrapolate the vector of the bullet trajectory and a vector from hit point to head bone center and do a dot product for an equivalence test. If inside bounds you now have a vector to point at the ragdolls head to apply force and a method to apply damage decals by finding the UV coordinate of the hit point on the mesh.
Your clips demonstrated nothing of note. Your explanation provided no procedure the OP could incorporate. Stop spamming your game. Also.what’s with the psychopath cackle after shooting somebody??
Its cheap, easy to setup and use (no extra colliders bs and related issues), quite performant, includes editor.
Cons - code is a bit messy, but that’s what you get for 15$.
Paint tris with tags, check against lookup what tag has been hit, apply damage multiplier.
Its really good for testing tricky geometry, as well as skinned mesh renderers.
Colliders won’t get modified by skinning, resulting in an incorrect hits during animations (e.g. when geometry bends).
So it depends on the game / design whether its appropriate - and simple collider wasn’t good enough for my case.
Also, setting up additional colliders and layers is quite user bug-prone.
Actually, “custom collision detection” may end up being more performant in circumstances like that.
A raycast is going to query entire physical subsystem which is at least logarithmic complexity. When you already know that you hit the capsule and need to check if you hit the head that’s going to be significantly faster.
Its physics internal data structures rebuild that is costly in this case.
When having colliders on bones, animator modifies them constantly.
If you’ve got like 20-50 of them per opponent - it will impact performance quite a lot.
(Also, even moving them in this case will be quite costly)
Keep blithering pal. Your setup has nothing to do with the OP’s question. His question was how to translate a hit on a capsule to a not already instantiated ragdoll. There is no triggers nor colliders on body parts to get hits from. Your lack of self awareness in your arrogance is cringe worthy.
If we are to nitpick, the query is provided by PhysX, meaning the call will be going through a middleman while passing C#/C++ boundary. Meaning a manual test might end up being faster, even if it is written in C#.
Triggers would be placed into the same space optimization structure as non-triggers, though.
Additionally, if you already have a hundred of them then you can’t use direct query to the collider, because you’ll lose optimization. Judging by cursory glance, physx is using BVH, aabb-based.
OP, the easiest way would be to produce a sphere collider for the head, even if it is not a part of the ragdoll. Or a replacement for that collider and check for headshot manually.