Description
Changelog
Reviews (0)

Health, hitbox and hurtbox components for Godot 4. A passive hitbox deals the damage, an active hurtbox receives it, and a sword with a quick and a heavy attack gives you something to test them with.

The crosshair in the GIF stands in for your mouse.

Features

  • HealthComponent: a drop-in node with damage(), heal(), is_alive(), get_ratio() and damaged, healed and died signals.
  • HitboxComponent: an Area2D that deals damage. It carries damage, knockback_force and is_crit, and never reads overlaps itself.
  • HurtboxComponent: an Area2D that receives damage. It detects the hitbox, applies the damage to its sibling Health, knocks its body back, and plays the hit flash, impact particles and a damage number.
  • One hit per swing. A swing hits each target once, even when the hitbox overlaps it for several frames. reset_hits() starts the next swing.
  • I-frames with one flag: hurtbox.invulnerable. The player's dash sets it, so you can dash through damage.
  • A two-attack sword driven by a small IDLE -> WINDUP -> ACTIVE -> RECOVERY state machine. The hitbox is only enabled during ACTIVE.
  • Impact feel: hit-stop, screen shake, a directional camera kick and a zoom punch on heavy hits, through one GameManager autoload.
  • Named physics layers in project.godot, so the layer checkboxes in the Inspector say player_hurtbox and enemy_hitbox instead of numbers.

Requirements

  • Godot 4.7 or later, standard build (GDScript only, no .NET needed).
  • Tested on Godot 4.7.2 stable on Windows. Earlier 4.x versions are untested.
  • Uses the Mobile renderer, which needs Vulkan, Direct3D 12 or Metal.

Quick Start

  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 that winds up first.
  4. Space to dash.
  5. Smash the barrels, then walk into the spikes on the left, then dash through them.

Known Limitations

  • The hurtbox reacts when a hitbox enters it. Standing still inside a hazard does not keep hurting you. For damage over time, add a timer that calls health.damage() while the overlap lasts.
  • Hit-stop sets Engine.time_scale to 0 for a few hundredths of a second, which pauses everything that runs on scaled time, not just the fighters.
  • No enemies fight back here. The player's hurtbox is tested with the spike trap.
  • No sound. HurtboxComponent.hurt and HealthComponent.died are the natural places to play one.
  • Death fades the player out and stops input. There is no game-over screen; the demo restarts with R.
  • Tested on Godot 4.7.2 on Windows only.

License

MIT for the code. See LICENSE.

Third-Party Assets

The knight, sword, barrel and spike sprites are from Tiny Dungeon by Kenney, released under CC0 1.0. Details in THIRD_PARTY_ASSETS.md, and the pack's original license is in Assets/Tiles/License.txt.

Learn How It Works

Want to understand how this works instead of just copying it?

CodingQuests teaches you how to build systems like this step by step in Godot, with interactive lessons and real projects.

  • 2D Roguelike: Combat Core builds this damage system lesson by lesson: the health component, the hitbox and hurtbox contract, the sword and the dodge. The first 4 lessons are free.
  • New to Godot? 2D Roguelike: Top-Down Controller builds the movement and dash this project starts from. Free, 8 lessons.

Source code, integration instructions and issue tracker: https://github.com/CodingQuests/godot-hitbox-hurtbox

Changelog for version 1.0.0

2026-10-17 01:26:50

No changelog provided for this version.

Reviews

Hitbox Hurtbox has no reviews yet.

Login to write a review.

Consider supporting the creators!

If you enjoyed this asset consider supporting its creator. Follow the link below.