Rectagonal Hitboxes

Why is it that collision boxes still have to be boxes and not other shapes that would better conform to the body of sprite?

Simple collisions like squares or circles on a 2d plane are extremely cheap and processor efficient. You could arbitrarily draw shapes on a 2d plane and compare if they overlap if you wanted to, but this costs more processing power per-frame.

The thing is, modern CPUs are actually powerful enough to do this. Game Maker games support arbitrarily shaped collision bodies. This is many times more expensive than rectangle collisions, but modern CPUs can totally handle it. The trouble is that it’s also a lot more time consuming to produce, and less consistent.

When you place rectangles, you can compare each frame to the last frame to see if they match up. You can reuse the rectangles even. You can easily scale something down if it sticks out too much, you can check exactly how high up a hitbox is and whether it will hit or miss another hitbox. That, and there’s a ton of weird shit that happens when hitboxes are too close to the model, like gaps between characters’ limbs, bits of the characters’ hittable area that stick out slightly too much. Tons and tons of glitches in all sorts of games are caused by having more complex hitboxes than necessary, which allow the characters to push through things, or miss by being too close or triggering a certain animation at the right time.

The basic idea is, if you keep it simple enough, then it’s a lot easier to build, debug, and results in less weird hitbox shit happening, like multihit combos (think chun li’s lightning legs) randomly dropping because the hit character moves slightly differently for a frame, or the edges of the character are drawn inconsistently between frames.

Probably the best example of this is SFV versus SFIV.
http://watissf.dantarion.com/sf5/boxdox/#cbt4/EC2-5MP-18

SFIV was known throughout its lifetime for having tons of ridiculous hitbox oddities that nobody could explain. SFV is keeping it simple, moving the boxes as little as possible, and it’s resulted in a vastly more consistent game to play and understand. I don’t think all games should go for this approach. I like games with highly articulated hitboxes, like smash bros, but it’s best to keep it consistent in most cases. And even smash uses more general hitboxes for stage collision.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s