Touching an enemy or environmental hazard deals damage to the player without any explicit attack trigger from either party.
The Mario rule: touching an enemy from the side takes damage and knocks you back, but landing on it from above stomps it flat.
The enemy's damage field. There's no attack trigger — any overlap with the player's hurtbox is the hit. Connect body_entered and apply damage.
func _ready():
body_entered.connect(_on_touch)
func _on_touch(body):
if body.has_method("take_damage"):
body.take_damage(TOUCH_DMG)Defines the dangerous region. Often slightly smaller than the sprite so contact feels fair rather than pixel-punishing.
# Child of the enemy's hurt Area2D; shape set in editor.
# Keep it forgiving — a touch smaller than the art.Layers decide who can touch whom. Put enemies on one layer and let the player's hurtbox mask only that layer, so contact damage is one-directional and clean.
# Player hurtbox masks the "enemy" layer only
set_collision_mask_value(2, true)In short: Area2D body_entered signal; any overlap between enemy and player hurtbox registers damage
…and 66 more in the interactive database →
146 catalogued game(s) use this mechanic, spanning 1985–1999.
▶ Explore Contact Damage interactively — see every game + the Godot system