Hitbox
An invisible geometric volume attached to attacks or objects used by the game engine to detect hits and collisions
Table of Contents
Interactive Playground
Tap or drag to interact with the demoWhat is Hitbox?
An invisible geometric volume attached to attacks or objects used by the game engine to detect hits and collisions. It is a core concept in Combat Design within Game Dev.
Core Principles
A Hitbox is an invisible, simplified geometric shape—such as a 2D rectangle (AABB), circle, or 3D capsule—used by a game engine to compute collision and attack detection efficiently. Testing exact pixel contours or high-poly meshes every frame is prohibitively expensive, so engines rely on fast overlap checks between primitive volumes.
In action and fighting games, designers separate Hitboxes (offensive zones that deal damage) from Hurtboxes (vulnerable zones that receive damage). During an attack's animation lifecycle—Startup, Active, and Recovery—the hitbox is only enabled during Active frames; the moment it intersects an opponent's hurtbox, a hit is registered.
Practical Takeaways
- Favor the player subtly: Rather than matching art pixel-for-pixel, make player attack hitboxes slightly generous and player hurtboxes slightly tighter than their visual silhouette. This creates fair-feeling dodges and crisp, satisfying strikes.
- Build a live debug overlay: Always maintain a toggleable debug renderer (e.g., red for hitboxes, blue for hurtboxes, green for world physics) so designers can audit frame-by-frame alignment instantly.
- Prevent tunneling on fast attacks: High-speed projectiles or dashes can skip past thin hurtboxes between frames. Use swept collision tests or raycasts between the previous and current positions.
Notable Examples
- Street Fighter 6: Separates hitboxes, hurtboxes, and pushboxes per frame, powering the deep spacing and footsies meta of modern fighting games.
- Hollow Knight: Pairs a forgiving nail slash hitbox with a compact player hurtbox to deliver responsive, razor-sharp 2D combat.
- Elden Ring: Uses multi-capsule weapon hitboxes swept along 3D swing arcs to interact accurately with dodge-roll invincibility frames.
Practical Code Snippet
Copy and drop straight into your projectpublic class MeleeHitbox : MonoBehaviour{ [SerializeField] private LayerMask hurtboxMask; [SerializeField] private float damage = 25f; public void CheckActiveFrame(Vector2 center, Vector2 size) { Collider2D[] hits = Physics2D.OverlapBoxAll(center, size, 0f, hurtboxMask); foreach (var hit in hits) { hit.GetComponent<IDamageable>()?.TakeDamage(damage); } }}