eli5: In a video game, why is it so hard to create hit boxes? And why aren’t they exact copies of the character model?

592 views

Hopefully this hasn’t been asked before on this sub, but I was wondering why so many games struggle with good hit boxes? Why are they even “boxes” in the first place? I would assume they would just be carbon copies of the character model instead of having individual boxes that stretch out over the characters body.

In: Technology

9 Answers

Anonymous 0 Comments

Frankly speaking, the math is hard and it can’t be done quickly. And as the geometry of the model increases in complexity from a cube into something with more vertexes the math complexity scales disproportionately.

Its been a long time since university, but I know there are simple algorithms for calculating whether a straight line (say a bullet path) intersects a cube, or how long/much of it intersects a cube. Easy. And compensating for the movement/rotation of the cube or the line for that matter is simple matrix transform math – modern cpus eat that up. But once you start trying to compute the boundaries or two cubes it gets harder. Change the cubes to cylinders and now we’re getting kinda difficult. Now the cylinders are complex constructs of cjoined cylinders, cuboids and triangular prisms – harder still. Now we’re a fully deformable mesh construct thing. Super hard to calculate collisions.

And by hard, I don’t mean the cpu couldn’t do it, I mean we could have a super accurate model-faithful hitbox for our players, but the calculations involved whenever collision detection was a thing would suddenly cause the CPU to grind to a halt.

So reducing the geometry of a hitbox to a reasonable compromise between collision/model faithfullness and compuation ease is something that game engine designers do all the time. Which is why its easier to develop in some regards for a console than PC because at least with the console you can right-size that compromise to deliver the best performance under most circumstances for most players – everyone has the same cpu.

You are viewing 1 out of 9 answers, click here to view all answers.