Contact DamageCombat

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.

How contact damage works in Godot

Area2Dnode

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)

CollisionShape2Dnode

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.

collision_layer / maskprimitive

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

Retro games that use contact damage

…and 66 more in the interactive database →

146 catalogued game(s) use this mechanic, spanning 1985–1999.

Related combat mechanics

▶ Explore Contact Damage interactively — see every game + the Godot system