Taking damage triggers a brief invincibility window during which further hits are ignored; the window length is a tunable design variable.
A hit applies knockback and brief stun, then invincibility frames during which the hero blinks and further hits pass through harmlessly.
Defines the invincibility window — the single most-tuned variable in feel. Start it on damage; while running, ignore further hits.
func take_damage(n):
if not $IFrames.is_stopped(): return # invincible
hp -= n
$IFrames.start() # wait_time = i-frame lengthThe blink. Pulse modulate alpha for the duration so the player can read that they're currently invulnerable.
func blink():
var t = create_tween().set_loops(6)
t.tween_property(self, "modulate:a", 0.2, 0.08)
t.tween_property(self, "modulate:a", 1.0, 0.08)Mechanically enforce invincibility by dropping the player's hurtbox out of the damage mask during the window, then restoring it.
$Hurtbox.set_collision_mask_value(2, false) # ignore enemies
await $IFrames.timeout
$Hurtbox.set_collision_mask_value(2, true)In short: Tween or Timer on damage; collision_layer toggled to exclude damage sources during invincibility; visual blink
42 catalogued game(s) use this mechanic, spanning 1986–1995.
▶ Explore Hit Stun i-frames interactively — see every game + the Godot system