Hey,
What’s the best approach for accurate, localized damage in a fairly realistic FPS where a simple capsule collider simply won’t do? I’m talking about collision being consistent with the character mesh and damage varying according to where an entity is shot — in the leg, in the torso, in the head, etc. The catch is that it’s a game for the Oculus Quest 2, so it can’t be too demanding.
The code doesn’t bother me too much; I’ll figure it out. But what about the setup? Should I have a single character mesh with primitive colliders as child of its bones? Sounds time-consuming and likely not very accurate. Should I have the character subdivided into meshes? I’m no expert but this sounds like it could cause issues with animation, in addition to being a performance hog.
Any idea? Assistance would be greatly appreciated. Cheers!
I would start by defining it all thoroughly.
What does this mean?
Does getting hit in the leg mean that you walk with a limp now? How are you going to do the limp?
Or does it just mean that 100 points of damage there only counts for 10 points?
One approach is to have separate colliders on all the separate things.
The damage handling script would have public references to each collider and determine what was hit by the projectile.
public Collider MyHead;
public Collider MyTorso;
public Collider LeftLeg;
//etc.
That way you would compare what collider was hit and decide how to damage.
Thank you for your response.
The code really isn’t a problem; what I’m not sure about is how to set the character up. You mentioned “separate colliders on all the separate things”; do you mean adding and resizing colliders as children of every body segment for every character? That would include custom colliders for at least the head, torso, upper & lower arms and upper & lower legs for a total of 10 colliders per character. Isn’t that going to be a problem down the line when it comes to workflow, accuracy or performance?
If you need to know which of 10 things you hit, I’m not sure how else you could do it.
I suppose you could have some whacky meta thing that analyzes the bones in a given character and tries to produce colliders on the fly, so you don’t have to manually do them for each character, but that usually ends up being brittle and hard to tune.
Alternately you could take the hit coordinate relative to the player and try to decide what was hit, but that would break down if the character was aggressively animated.
Sounds a bit speculative. Who knows? You may think you will have 97 character variants and then later find you only have to have 3 or 4… that changes the economics quite a bit.
I don’t really need to know which of the ten I hit in all cases; upper arm and lower arm don’t really need separate damage multipliers, typically. But since upper arm and lower arms are separate anatomical segments, you can’t have an accurate collider that covers both AFAIK.