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.

Timing diagram The 1.2 s after a hit
With the technique Ignored: 500 ms of i-frames left.
Without it You lose another mask: contact damage tries again every tick.
Drag the marker or use the arrow keys: it is the moment you press.
  • 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 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

1 · technique on 2 · T pressed: off 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.

The in-game labels are in Spanish.

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
## 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
@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 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.