Skip to main content
Coding Quests

Godot Hitbox and Hurtbox

Damage code gets tangled when every weapon checks every enemy itself. These three components split the job. A hitbox deals damage, a hurtbox receives it, and a health component keeps the numbers.

Free Godot 4.7 project · MIT licensed · v1.0.0

No account needed. Or download the v1.0.0 ZIP directly.

Slashing barrels, landing a heavy critical hit, then dashing through spikes without taking damage.

What is in it

  • A health component with damage, heal and death built in.
  • Hitbox and hurtbox components built on Area2D, the Godot node that detects overlaps.
  • One hit per swing, even while the hitbox keeps overlapping the target.
  • I-frames with a single flag. The dash sets it, so you can dash through spikes.
  • A sword with a quick attack and a heavy attack that winds up first.
  • Impact feel: hit-stop, screen shake, a camera kick and a zoom punch.
  • Named physics layers, so the layer checkboxes in the Inspector say what they are for.

Quick start

Download the project from GitHub and unzip it. In the Godot Project Manager, click Import and pick the project.godot file inside the folder.

  1. Press F5.
  2. Move with WASD and aim with the mouse.
  3. Left click for a quick slash, right click for a heavy attack, Space to dash.
  4. Smash the barrels, walk into the spikes, then dash through them.

The README on GitHub explains how each part works and how to copy it into your own game.

Compatibility and limits

Made for
Godot 4.7, standard build. GDScript only, no .NET needed.
Tested on
Godot 4.7.2 stable, on Windows. Earlier versions of Godot 4 are untested. Uses the Mobile renderer, which needs Vulkan, Direct3D 12 or Metal.
Renderer
Mobile
Code license
MIT. You can use it in commercial games. Read the license
Art and fonts
Knight, sword, barrel and spike sprites from Kenney's Tiny Dungeon pack (CC0 1.0).
Release
v1.0.0, commit 1b33150, published 2026-10-03

Known limits

  • Damage happens when a hitbox enters a hurtbox. Standing still in a hazard does not keep hurting you.
  • Hit-stop pauses everything that runs on scaled time, not just the fighters.
  • No enemies fight back. The player's hurtbox is tested with a spike trap.
  • There is no sound.

Learn to build it

Copying a system works until you need to change it. These quests build it with you, one small step at a time. You write the GDScript in your browser and each step is checked before you move on.

2D Roguelike: Combat Core

Builds this damage system lesson by lesson: the health component, the hitbox and hurtbox contract, the sword and the dodge.

First 4 lessons free

2D Roguelike: Top-Down Controller

Builds the movement and dash this project starts from.

Free, 8 lessons

See all the free Godot projectsReport a problem with this project