- Home /
Fastest way to add calculate damage on different body areas (hit boxes)
What I ask is, what is the fastest way to replicate hit-boxes, like for headshots? I am currently using box colliders for my characters but it really lowers the performance. With about ten characters in my scene the FPS drops from 300+ to <100.
I know it is the colliders because when I disable all the colliders, but keep all the animations and AI running, the FPS shoots up to 300+ again. What would you guys suggest to replace my box colliders or improve the performance?
Answer by Taxen0 · Jan 12, 2015 at 09:07 AM
Colliders is the way to go, I can't think of any other way to do this.
Performance should not be an issue, i have a scene with a few thousand objects with colliders and it works fine.
Have you added a rigidbody to the characters, or made the colliders static?
I have tried adding rigid-bodies, but that made it slightly slower for me. Would adding rigid-bodies be better if I marked the limbs as static?
moving static colliders is very heavy on the CPU, and a collider without a rigidbody counts as static if I'm not mistaken.
So have one rigidbody on your object and then add the colliders (not static). You can also make sure the colliders only check for collisions with relevant layers, see this article from the Unity $$anonymous$$m: http://unity3d.com/learn/tutorials/modules/intermediate/physics/physics-best-practices
This is strange, I put a rigid body on the main object, then set the physics of the hitboxes to ignore everything. Problem is, with rigid body = 30-40 FPS without rigid body = 80-90 FPS.