Skip to main content

How hitboxes work

(Image credit: Sea Leaf Dojo)

When you ask a game developer about hitboxes you'll get a range of reactions. One developer responded to my call for insight with "Ugh, hitboxes."

Another: "This has been the thing I've been obsessed with for 20 years."

Hitboxes are the invisible geometry that tells a game when and how things collide, which doesn't sound like an emotional topic. But while hitboxes are essential to most games, they're also weird and difficult. They sit in a thorny tangle of hard math and player perception of what's happening in a game and what's "fair." Hitboxes are an attempt to make a game behave the way players think it should, and that makes them a massive design challenge which involves cheating the details, taking shortcuts, and obsessing over tiny changes. In short, a good hitbox is hard to make, a problem game developers have to solve over and over again. 

What is a hitbox?

Hitboxes are so elemental to games that whether you're conscious of them or not, you're always playing around them

There are all sorts of reasons a game needs to know when things are colliding: When a fighter in Mortal Kombat has landed a punch, whether you've successfully drifted past a bandsaw in Super Meat Boy, or if an operative's .45 has scored a headshot in Rainbow Six: Siege.

Hitboxes work both ways. You need a hitbox for a thrown fist or spinning blade—the thing doing the hitting—and another for the thing getting hit, often called a "hurtbox." A collision takes two, after all. But whatever the type of hitbox, the rules for how they work aren't set in stone. Different games take different approaches to their shapes, sizes and behaviour.

For example, your character's hitbox in Dark Souls pretty much exactly matches your visible model as you move around, precisely enough that you can avoid getting hit by some attacks by simply changing your stance. In this example, as played by Dark Souls speedrunner catalystz, performing a block with the right timing places his feet just far enough apart that Gravelord Nito's Greatsword harmlessly passes between them.

The same goes for the Monster Hunter series, in which the hitbox has followed the player and the monster models faithfully since Monster Hunter Tri in 2009.

"It only improved from there," says SD Shepard, a Monster Hunter speedrunner and streamer and 2018 North American Monster Hunter World Champion. "In World, they're very accurate and specific to the monster."

Hitboxes are so elemental to games that whether you're conscious of them or not, you're always playing around them, feeling out their shapes and the flexibility they offer. For speedrunners, though, it's a more conscious effort.

"95 percent of the time I'm thinking about them!" says SD Shepard. "A lot of people get really hung up on Monster Hunter because they're worried they don't know how to play their weapon, but for the most part, weapons are simple. When I try to tell people how to get better, I tell them not to hit the monster but to stand there and watch how the monster moves. When it attacks, see where you have to be standing relative to it so they can't hit you, or when you can evade."

For third person 3D action games like these, having your hitbox match your body makes sense. This visual consistency helps you to understand what's happening and therefore learn how to play.

Shmups take a different approach. Their hitboxes are usually much smaller than the player character (or ship), to help you dodge through screens full of bullets. Making the hitbox the full size of the ship would be more difficult and more frustrating. Indie shmup Blue Revolver actually has an option to highlight the ship's hitbox. It's so tiny, it's hard to spot.

(Image credit: racercowboy on Steam)

Abstract music-action game Endlight works off this classic shmup approach. In Endlight your ship has three hitboxes, depending on situation. The one that collides with walls is much smaller than you, to give you wiggle room. The one that collides with the hoops you're aiming to collect is slightly larger, helping you to feel skillful. And there's one which is three times the size of your ship, and triggers a 'whoosh' sound when you pass near walls and obstacles. Not all hitboxes are for fighting.

(Actually, the whoosh hitbox has two sizes. Every other frame it's 10 times the size of your ship; large obstacles that collide with it trigger the whoosh sound. The effect is that small obstacles only whoosh when they're close by, and large ones whoosh from further away. The point is, hitboxes are complicated.)

Designing fun hitboxes

Disc Room uses hitboxes to create effects that emphasise the action of its instant-death, high-velocity sawblades. It subtly shakes the player character when you're really close to a sawblade. You hear it whooshing by with a doppler effect, and even time itself slows down slightly.

"It notifies you of the danger and gives you more time to react," says Jan Willem Nijman, one of the developers. "Basically, we want exciting moments to happen as often as possible. It feels much better to make an impossible escape than to die from something that looked easy."

Those discs are a good example of how varied hitboxes can be: the area where the sawblades are actually lethal is well within their teeth. And a faster disc actually has a smaller hitbox.

The gray circle on the right shows the blade's actual hitbox (Image credit: Terri, Dose, Kitty, and JW)

Disc Room's hitboxes don't only exist in space—they also exist in time. "You're actually allowed to be inside a hitbox for up to 50 milliseconds, roughly three frames, before you die. This is not really long enough to react, but it has a bunch of good side effects that make it seem like the game knows your intentions."

That's what hitboxes are really trying to do: Make the outcome of the game match up with what you expect. What that means varies from game-to-game, so hitbox design and implementation is far from universal. From here on, Nijman and his team will be sweating the details: Should a dodge roll change when the player's inside the perimeter of a disc? When time is slowed, should the player hitbox become even smaller?

"We haven't gotten to the bottom of this yet, and probably will keep learning and discovering until the very end of the project."

Perfecting the hitbox

(Image credit: Komi Games)

There's something about a circle that you intuit; a radius around you that's safe.

Metanet's Raigan Burns

Developer Metanet spent a full 10 years tweaking and polishing the hitboxes for their classic ninja platformer N, right into the closing weeks of N++. "The gold collision shape became a little bit bigger, the mines a little bit smaller, so it's less frustrating, less clunky to get around," Mare Sheppard says.

"You figure out your plan for how you want things to go, and these tiny changes help that plan become more likely to be successful, without making you feel the game is unfair or too generous."

Developer Julian Spillane has been grappling with that iteration while making arena fighter Mighty Fight Federation, which was released into Early Access this year. Players quickly complained that one character, who needs to get up-close and personal to deal damage, was underpowered and didn't have the abilities needed to close that gap.

"I realised it didn't have anything to do with that," Spillane said. "The hitbox on his jab just wasn't exaggerated enough to allow him to land the first blow to start a combo. So yeah, it's unrealistic for a jab to have a big hitbox, but because he has nothing far out, it's worth exaggerating it so it's rewarding when they dodge and evade everything coming their way to get in and get the combo."

What are hitboxes made of? 

Despite the name, hitboxes aren't always "boxes." While Dark Souls, Monster Hunter World, and Apex Legends hitboxes follow the form of the characters, more or less, in other genres, from platformers to fighting games, they take many shapes: Spheres, lozenges and capsules.

Fighting games still generally use the square hitboxes established by Street Fighter 2, with some outliers like Marvel vs. Capcom, which uses circles. In the 3D melee of Mighty Fight Federation they're usually spheres and rarely cubes. "With the harsh edges of a cube you get too many false positives for hits," says Spillane.

In platformers, they're commonly circles. They help N++ feel more natural: the ninja tends to round sharp corners rather than graze up or across them.

"If you look closely, there's a lot of empty space in the circle, and frame-by-frame you'll see you do get hit by things the graphics aren't touching," says Raigan Burns, the other half of Metanet Software. "But people don't really notice. There's something about a circle that you intuit; a radius around you that's safe."

(Actually, N++'s ninja is also sometimes a square. "It was too awkward to have the player tip over the edges of the thwomp enemies," says Burns. "So it's a bit inconsistent, but in a way that makes the game easier to play and less frustrating.")

Doing the math

(Image credit: Metanet)

While hitbox design is pretty well understood, their technicalities are still a difficult science.

"This has been the thing I've been obsessed with for 20 years," says Burns. "It's an open problem. No one has solved it. I feel like I finally understand what makes it complicated, but I don't know if I can explain it."

The gist: While it's easy for us humans, residents of the physical world, to understand the concept of one thing hitting another, the maths of working out overlapping volumes is not so easy. And the number of collision events a game needs to calculate presents huge overheads.

Think about Doom Eternal as a simple example: Every frame, it has to check the player hitbox against the ground and every wall in the level, and every demon and object. Then it also has multiple hitboxes for each demon so they respond to projectiles differently, and each bullet and projectile has to be seen to hit walls, floors and objects. We're talking thousands of checks, 60 times or more per second.

For Endlight, which has many objects on-screen at once, developer Jim McGinley had to optimise the game by reducing the number of checks on immobile objects and ignoring objects that are far away from the player. Since the game is on-rails, McGinley knows that each object will arrive at the player 20 seconds after spawning, so they're only given a hitbox when they're 18 seconds old (for an idea of how important this tiny detail, he calls this "Endlight's greatest trick").

There are other problems: Most games calculate the state of a game for every frame, which can allow fast-moving objects to clip through walls. To the computer they never collided, since that moment occurred between frames. The solution is for the game to look back at the path an object took since the previous frame. If the path intersects with another object, they must have collided. The truth behind these sorts of problems is that games are patchwork simulations that are doing all they can to fool us into seeing them as cohesive worlds.

"Everything in games is about perception, and we're playing sleight of hand with our gamers every single frame," says Spillane. When hitboxes are done badly, games seem unfair; they break with our expectations. "The illusion and the fun are ruined. I don't think anyone has perfected it, but obviously there are games that people feel are more universally fair than others."

"When hitboxes are done well, you won't even have to think about them," says Nijman. "It will feel exactly as you predict."