A hitbox is where an attack deals damage. A hurtbox is where a character can take it. A hit is one overlapping the other, and a third box, the body, only bumps into floors and walls.
| Box | Size | Against the drawing |
|---|---|---|
| Player body | 24×36 px | it's the collision shape |
| Player hurtbox | 16×28 px | smaller: a graze doesn't count |
| Player slash hitbox | 88×56 px | bigger: the exact one is 48×28 |
| Enemy hurtbox | body + 6 px | bigger: easy to hit |
| Enemy contact hitbox | 60% of the body | smaller: brushing past is free |
Hitbox, hurtbox and body: three boxes, three jobs
Infil's Fighting Game Glossary defines a hit the same way, and gives the color convention most training modes use: hitboxes red, hurtboxes green. Fighting games call the third box the pushbox. Here the body is what collides with the world, and it never deals or takes damage.
Generous hitboxes: big for the player, small against them
None of the three should match the drawing. Make every disagreement favor the player: the slash reaches 80 px from the center instead of 60, is 56 px thick instead of 28, and starts 8 px behind the center so a point-blank slash still lands. Enemies are easy to hit, and while they just walk around only their core hurts. When they attack with the body itself, that box grows to the body minus 8 px.
Fighting games keep hurtboxes close to the model, because every pixel you give one player you take from the other.
How to implement hitboxes and hurtboxes
- One body, two areas. The body collides with the world. The hurtbox can be found but looks for nothing, and the hitbox looks but can't be found.
- One layer per team. Put each team's hurtboxes on their own layer and point every hitbox at the other team's. A hitbox never even sees an ally, so there's no team check anywhere.
- One hit per activation. Keep a list of what the attack has already hit and clear it when the attack starts. Without it, a slash active for 100 ms hits the same target twelve times at 120 ticks per second.
The code in Godot 4
func _init() -> void:
monitoring = true
monitorable = false
collision_layer = 0
# ...
func _ready() -> void:
collision_mask = CombatLayers.hurtbox_bit(CombatLayers.opponent(team))
# ...
## Empiezan los frames activos: la lista de golpeados se vacía.
func begin() -> void:
active = true
_already_hit.clear()
# ...
for area in get_overlapping_areas():
var hurtbox := area as Hurtbox
if hurtbox == null or not hurtbox.enabled:
continue
if not continuous and hurtbox in _already_hit:
continue
var hit := _make_hit(hurtbox)
var result := hurtbox.receive(hit)
if not continuous:
_already_hit.append(hurtbox) The hurtbox is the mirror image: monitoring = false, monitorable = true, and its layer is its own team's.
Quick answers
Is a hurtbox the same as a hitbox?
No. The hitbox belongs to the attack and the hurtbox to whoever gets hit. People often say "hitbox" for both, which is how complaints about someone's "hitbox" end up being about their hurtbox.
Should the hitbox match the sprite?
Not in a single-player action game. The slash box here has about 3.7 times the area of the drawn slash, and the player's hurtbox is smaller than the body. Match the drawing only when fairness between two humans is the point.
Discussion
Comments are hosted on GitHub Discussions — sign in with GitHub to reply.