---
title: "Invincibility frames (i-frames) and spikes that don't kill"
description: "Invincibility frames are the window after a hit where nothing can hit you again: 1.2 s here. Spikes cost a mask instead of a life. See both and play them."
date: 2026-11-18
url: https://valdemird.com/blog/health-damage-invincibility-frames/
lang: en
tags: ["game-feel", "game-design", "godot", "combat"]
---

**Playable sheet: Health and damage** (the real game, in the page)

- Video: https://valdemird.com/videos/play/platformer-lab/combate-c_health.mp4 (Walks across the damage pad. With invincibility frames it loses one mask and blinks through; after T each contact costs another mask.)
- Play: https://valdemird.com/play/platformer-lab/index.html?plano=combate&lamina=c_health&lang=en

How to try it:
1. Walk right with → onto the damage pad. You lose one mask, get knocked back, and blink for 1.2 s.
2. Jump into the pen with Space and stand inside a walker. With i-frames it can only take a mask every 1.2 s.
3. Press T to switch the i-frames off and walk over the pad again: every contact costs another mask.
4. Dash through a walker with X. The dash has i-frames of its own.

# Invincibility frames (i-frames) and spikes that don't kill

> Invincibility frames are the window after a hit where nothing can hit you again: 1.2 s here. Spikes cost a mask instead of a life. See both and play them.

**Invincibility frames** (i-frames) are the window after a hit where nothing can hit you again. Here it lasts **1.2 s**, you blink the whole time, and a mistake costs one mask instead of one per tick.

**The 1.2 s after a hit.**
- i-frames (1.2 s): with the technique, Ignored: n ms of i-frames left. Without it, You lose another mask: contact damage tries again every tick.

I-frames after a hit: one mistake, one mask

Contact damage is why they exist. An enemy's body or a damage pad is a hitbox that's always on and tries to hit you on every physics tick, 120 times a second. Without the window, standing inside an enemy for an instant would cost a mask per tick. The hit also knocks you back and takes your control for 0.2 s; the rest of the 1.2 s is time to get clear. Health is five masks, the same as [Hollow Knight](https://hollowknight.wiki.fextralife.com/Health+Mask) starts you with.

Hazard respawn: spikes that cost a mask, not a life

Spikes, pits and the void don't kill. They cost a mask and put you back on the last safe ground you stood on; only the last mask sends you to the checkpoint. Health is the error budget for the area, and a spike shouldn't make you replay what you already knew how to do. I-frames never protect you from spikes, or an enemy hit would buy you 1.2 s to cross a spike pit.

**Playable sheet: Environmental damage** (the real game, in the page)

- Video: https://valdemird.com/videos/play/platformer-lab/combate-c_hazard.mp4 (Walks into the spikes on purpose. With hazard respawn it loses a mask and reappears on the last safe ground; after T the spikes kill and it starts over from the checkpoint.)
- Play: https://valdemird.com/play/platformer-lab/index.html?plano=combate&lamina=c_hazard&lang=en

How to try it:
1. Walk right with → into the first spikes. You lose one mask and reappear on the last safe ground, not at the checkpoint.
2. Keep holding → when you reappear. It doesn't move you until you let go (half a second at most), so the same reflex doesn't put you back on the spikes.
3. Jump the spikes with Space and drop into the pit at the end: the void works the same.
4. Press T and touch the spikes again. Now they kill, and you start over from the checkpoint.

How to implement i-frames and hazard respawn

1. **One invulnerability timer in the health component.** A hit that lands sets it; while it runs, every hit is refused and contact hitboxes try again next tick.
2. **Knock the player away on a hit.** If they're still inside the enemy when the timer runs out, the next hit lands on the very next tick.
3. **Let the movement code ask before it dies.** For a hazard, charge a mask and send the player to the last safe ground instead. Only record ground that's really safe: static, with floor on both sides and no hazard nearby.
4. **Make hazard hits ignore invulnerability.**

**The code in Godot 4.**

`addons/combat_kit/core/health.gd`:

```gdscript
## Aplica un golpe. Devuelve false si no hizo efecto (ya muerto o invulnerable).
func take(hit: Hit) -> bool:
	if is_dead():
		return false
	if _invulnerable > 0.0 and not hit.ignores_invulnerability:
		return false
	current = maxi(current - hit.damage, 0)
	_invulnerable = invulnerability_time
	changed.emit(current, maximum)
	damaged.emit(hit)
	if current == 0:
		died.emit(hit)
	return true
```

`addons/combat_kit/player/combat_params.gd`:

```gdscript
@export_group("Vida y daño")
@export_range(1, 12) var max_health := 5
## I-FRAMES: invulnerabilidad tras recibir daño. Tiempo para salir del peligro.
@export_range(0.0, 3.0, 0.05, "suffix:s") var invulnerability_time := 1.2
## Empujón al recibir daño: horizontal (alejándose del golpe) y vertical.
@export var hurt_knockback := Vector2(300.0, 330.0)
## Tiempo sin control tras el golpe: el empujón se nota, pero no desespera.
@export_range(0.0, 0.6, 0.01, "suffix:s") var hurt_lock_time := 0.2
```

The blink reads the same timer, so it stops exactly when you can be hit again.

Quick answers

How long should invincibility frames last?

Long enough to get out of danger: 1.2 s after a hit here, 0.2 s of it without control. A [dodge](/blog/dodge-dash-i-frames/) is much shorter: 0.21 s.

Should spikes kill or take health?

If your game has health, take health. Here a spike costs one mask and returns you to the last safe ground. Only the last mask kills.
