Health System
A modular health and damage system for Godot 4.7, set up in the inspector instead of in code.
Add a HealthComponent to your actor. Armor, resistances, shields, poison, potions, i-frames, loot drops, lives and health bars are nodes and .tres resources you configure in the inspector. A goblin with armor, a loot drop and a despawn on death needs no GDScript at all, and neither does the spike trap that kills it.
HealthComponent extends Node, not Node2D or Node3D, so the same profiles work in a platformer, a top-down shooter and a first-person game. Only the hurtbox and hitbox nodes contain 2D or 3D specific code.
Highlights
- No glue code: hitboxes, hurtboxes, actions and profiles replace the signal wiring you would otherwise write in every enemy script.
- 2D and 3D: one core, with
Hurtbox2D/Hurtbox3DandHitbox2D/Hitbox3Dfor both dimensions. - Modifier pipeline: armor, resistances, multipliers, damage caps, blocks and shields run in a clear, documented priority order.
- Actions as resources: loot, sounds, animations, despawn, i-frames and events react to damage, healing, death, revival and health thresholds.
- Status effects: poison, burning, heal over time, with stacks, ticks and tags.
- Drop-in friendly: every node finds the health component of its actor on its own, also from a bone or a
Componentsfolder. - Editor support: custom icons, English tooltips on every property, configuration warnings in the scene tree and type suggestions in the inspector.
- Tested: more than 800 automated gdUnit4 tests, including integration tests that build the addon into a scene the way a foreign game would.
Quick start: an enemy in 60 seconds
- Build the scene:
Goblin (CharacterBody2D)
├── Sprite2D
├── CollisionShape2D
├── HealthComponent
└── Hurtbox2D
└── CollisionShape2D
- Create a
HealthProfileresource and save it asgoblin.tres:max_health = 30default_modifiers: anArmorModifierwitharmor = 3actions: aSpawnSceneAction(scene = coin.tscn,spawn_count = 2) and aQueueFreeAction
- Drag
goblin.tresinto thehealth_profilefield of theHealthComponent. - Add a
Hitbox2Dwith a collision shape to your spikes and setdamage = 10.
The goblin now has 30 HP, takes 3 less damage per hit, drops two coins when it dies and removes itself from the tree. Every other enemy is another .tres file, not another script.
When you do want code, the API is small:
var health := HealthComponent.find(goblin)
var result := health.damage(10.0, self, &"fire")
print(result.final_amount) # 7.0, the armor took 3 off
What is included
Core
- HealthComponent: stores health, runs the modifier pipeline and emits signals for damage, healing, death, revival, health and max health changes, thresholds, tags and modifiers.
damage(),heal(),kill(),revive(),grant_invincibility()andget_health_percent(). Settingcurrent_healthormax_healthdirectly follows the same rules as a hit. - HealthProfile: one
.tresfile per actor type: max health, start health, percentage thresholds, default modifiers and actions. Every actor gets its own copies, so one profile can drive any number of enemies. - DamageInfo, HealInfo and DamageResult: amount, source, type, hit position and free-form metadata in; final amount, blocked amount, overkill, lethal and blocked out. Modifiers work on a copy, so one info can hit several targets, for example from an explosion.
- Tags: counted tags such as
invincible,poisonedorburninglet the rest of your game react without knowing about modifiers.
Modifiers
| Modifier | Priority | Effect |
|---|---|---|
ArmorModifier |
20 | flat reduction with a minimum damage |
ResistanceModifier |
50 | multiplier per damage type: immunity, resistance, weakness |
DamageMultiplierModifier |
50 | multiplier for all damage or one type |
HealMultiplierModifier |
50 | multiplier for healing, e.g. grievous wounds |
DamageCapModifier |
80 | limit per hit, flat or in percent of max health |
BlockAllDamageModifier |
90 | blocks everything, e.g. for i-frames |
ShieldAbsorbModifier |
95 | draws from a ShieldComponent |
Modifiers can be permanent or timed. Timed ones stop while the game is paused, and hitting again refreshes them instead of stacking them. Writing your own takes one class with one method.
Actions
Actions react to ON_DAMAGED, ON_HEALED, ON_DEATH, ON_REVIVE and ON_THRESHOLD. Every action has filters: chance (e.g. loot in 30 % of all deaths), only_types (e.g. only fire damage), skip_if_blocked, only_thresholds and direction.
QueueFreeAction: removes the actor, optionally after a delaySpawnSceneAction: spawns loot or effects at the actor, with a scatter radiusApplyInvincibilityAction: i-frames after a hitPlaySoundAction: positional sound with pitch variation that survives the actor's removalPlayAnimationAction: plays on anAnimationPlayer,AnimatedSprite2DorAnimatedSprite3DCallMethodAction: calls any method on a node of the actor, the bridge to the rest of your gameApplyStatusEffectAction: e.g. fire damage sets the actor on fireEmitEventAction: sends a named event for your event bus
Example without a script: a boss shows its enrage sprite at 25 % health with a CallMethodAction set to ON_THRESHOLD, only_thresholds = [25], direction = GOING_DOWN, target = EnrageSprite and method = show.
Hit detection
- Hurtbox2D / Hurtbox3D: receive hits for the actor.
damage_multiplieron a head hurtbox gives you headshots. Any area with adamagemetadata entry, such as lava, deals damage without a script. - Hitbox2D / Hitbox3D: the attacking side. Per hit they deal damage, heal, apply a status effect or add a modifier, either once per entry or repeatedly while an actor stays inside. An actor is hit once even if its body and hurtbox overlap at the same time.
target_grouplimits targets,free_on_hitturns a hitbox into a pickup or projectile, and a hitbox never hits its own actor.
| Thing | Setup |
|---|---|
| Spikes | damage = 10 |
| Poison swamp | status_effect = poison.tres, mode = WHILE_INSIDE |
| Healing potion | damage = 0, heal = 30, free_on_hit = true |
| Cursed blade | damage = 10, modifier = grievous_wounds.tres, modifier_duration = 10 |
Modules
- ShieldComponent: a separate shield pool in front of the health, with break and restore signals. Invincibility protects it too.
- RegenModule: regeneration over time, optionally only after a delay without damage.
- StatusEffectModule: runs
DamageOverTimeEffect,HealOverTimeEffectand your ownStatusEffectresources with stacks, ticks and tags. Hitboxes add it to an actor automatically. - LivesComponent: lives, game over and respawning at a
respawn_pointwith respawn invincibility.lives_changeddrives a lives display. - HealthBar: a themeable
ProgressBarwith animation, a damage trail and auto-hide. Place it inside the actor for a bar above its head, or settarget_group = "player"for a HUD in a different scene.
Editor
- Icons for every node and resource
- Tooltips on every exported property
- Configuration warnings when a node cannot find its
HealthComponent, or when a hitbox is set up to do nothing - Your game's damage and heal types under Project Settings → Health System → Types, suggested in every type field, so
"Fire"and"fire"cannot drift apart
Demo
The repository contains two demo scenes.
- Arena: a poison swamp, a healing potion, an enemy that inflicts grievous wounds, a boss with an enrage phase and loot drop, and a player with lives and respawning. All of it is configured in the inspector. The only scripts are player movement and the HUD's lives and status display.
- HealthBar demo: try out damage, healing, death, revival, max health changes, animation and the damage trail.
Installation
- Copy
addons/health-system/into your project, or install it from the Asset Store. - Open Project → Project Settings → Plugins and enable health-system.
- Add a
HealthComponentto your first actor.
The addon has no dependencies. The editor icons are included, no icon plugin needed.
Requirements
- Godot 4.7 or newer
- GDScript only, no C# or GDExtension
- 2D and 3D
Documentation and source
The full README covers every class, signal and convention, plus step-by-step guides for writing your own modifiers and actions. The changelog lists every change per version, including upgrade notes.
Source, issues and releases: https://git.johnsoellner.me/swoopy/health-system
What's new in 1.1
Hitbox2DandHitbox3D, the attacking counterpart of the hurtboxes- Filters on every action: chance, damage types, blocked hits, specific thresholds, direction
- New actions:
CallMethodAction,PlayAnimationAction,ApplyStatusEffectAction,PlaySoundAction,EmitEventAction - Status effects, damage and heal multipliers,
LivesComponentandHealthBar - Hurtboxes work from anywhere inside the actor, with a damage multiplier for headshots
- Timers respect pause, damage before
_ready()works,max_healthclamps current health - Configuration warnings, type suggestions and English tooltips in the editor
- Many fixes from a review that built the addon into a foreign game
License
MIT. The editor icons come from the MIT licensed @icons set by Valentin Fossati (Voxybuns).
How it was made
The architecture and the 1.0 source code are hand-written. The tests, documentation, CI and the 1.1 review fixes and features were written with AI assistance.
Changelog for version v1.1.0
2026-10-23 15:52:00
No changelog provided for this version.