# What is a hit box?

What exactly is a hit box? Is there any way that knowing about hit boxes could help in a game?

-

Definition

A hitbox is an invisible box-like area that when penetrated, counts as a "hit". It's different than the model (the visible character and his colors that you see). The hitbox is meant to compensate for lag and movement. When a character is moving, his hitbox is usually farther from the model. When a character is still, his hitbox is located directly on top of his model.

Contrary to the name, a hitbox is actually composed of several boxes that represent the character's different areas (head, arm, torso).

Hitboxes, and You

You should definitely know how the hitbox affects you. It's the source of nearly all bizarre "WTF, how did I die?", and impossible shots that you see other players making. Understanding the hitbox is key to understanding how you die (and possibly getting better at your game).

Demonstration

A picture is worth a thousand words, so here's an excellent video from Team Fortress 2:

http://www.wegame.com/watch/TF2_Hitboxes/

Watch how the hitbox moves according to the model, where it moves and when, and lastly, understand where you need to shoot to penetrate that hitbox (and score).

Illustration

Below is a picture of hitboxes in Counter Strike. As these models are sitting still, the hitboxes are right on top of them.

-
Counter Strike? Looks like Day Of Defeat. – Denilson Sá Mar 11 '11 at 14:57

The main reason they use a hitbox for collision detection is that computing a hit based on geometry is increasingly expensive as the geometry gets more complicated. Typically there are actually multiple bounding boxes that are used. Partly, this is because a hit test against a rectangular box uses simple math and is very fast. If it misses the outermost box, they can shortcut the process and simply stop checking any further. A hit on the outermost box prompts a check for a closer box. However, they also don't want to recurse too far, or else it becomes too expensive (in time spent). At some point they must say, "that's close enough - it's a hit!"

One technique sometimes used for this is called an "octree", where 3D space is defined in terms of a recursive hierarchy of cubes. If two objects are in completely different branches of the octree, there is no possibility of them colliding so the detection can halt there. As they get closer to one another, the hit test becomes increasingly refined until the system knows that they have intersected or collided.

-
Excellent technical explanation. – Neil Aitken Jul 9 '10 at 22:25

A hit box is a region inside of which a character is placed.

It is an optimization used to speed up collision detection.

In a 3d shooter, for example, if you know what shape and size the hit boxes are, you could potentially aim for them, rather than the actual enemies. This could allow you to compensate for lag properly, or to get a head-shot when no part of the head is visible.

Here is an example:

-
Note that this is generally seen as cheating, especially in CS:S. – user56 Jul 9 '10 at 21:32
Really? I'm not a CS:S player, but I have a hard time imagining anyone considering knowing game mechanics to "cheating". I don't think "bunny-hopping" is thought of that way. – Jeffrey Jul 10 '10 at 3:59
I'm an Ex-CAL:M, and it was never considered cheating there. – John Gietzen Jul 10 '10 at 16:28
where are the free hand cir... ahem hitboxes? – mechko Jul 12 '10 at 3:59