A dodge dash grants invincibility frames while it lasts, so you go through attacks instead of over them. Here that's the 0.16 s of the dash plus 0.05 s for the exit, and a 0.45 s cooldown keeps mashing from making you untouchable.
- i-frames (210 ms): with the technique, Untouched: n ms of protection left. without it, Hit: without dash i-frames, you lose a mask.
- vulnerable gap (240 ms): with the technique, Hit. You can dash again in n ms. without it, Hit. You can dash again in n ms.
Dash i-frames: through the attack, not over it
Jumping dodges what comes along the floor, but it leaves you in the air and far from the enemy. A sideways dash dodges and places you: you come out on the other side, behind whoever attacked, with their recovery still ahead of them. The extra 0.05 s covers the instant after the dash when you may still overlap what you went through. Hollow Knight's Shade Cloak works the same way: it lets you "dash through enemies and their attacks without taking damage."
The cooldown rule: at least twice the protection
If the cooldown counts from the start of the dash, someone mashing the button is protected at most protection ÷ cooldown of the time. With 0.21 s of protection, a 0.22 s cooldown would make you untouchable 95% of the time, and the dash would become the fastest way to walk. At 0.45 s it's 47% at most, and between two dashes there's always a vulnerable gap of 0.24 s, longer than the protected one. The Shade Cloak recharges in about 1.5 s.
How to implement dash i-frames
- Don't add a dodge state. When the dash starts, grant invulnerability for its length plus a small margin, on the same timer the i-frames after a hit use.
- Cancel any attack in progress when the dash starts. Otherwise a slash thrown just before travels inside the dash, untouchable and hitting at once.
- Set the cooldown to at least twice the protection, counted from the start of the dash.
- Don't protect against hazards. Spikes and pits ignore invulnerability, or a dodge would cross any spike pit 3.6 tiles at a time.
The code in Godot 4
## Lo que dura de más la protección del dash respecto al dash: cubre la salida.
const DASH_GUARD_EXTRA := 0.05
# ...
player.dash_started.connect(_on_dash_started)
# ...
func _on_dash_started(_direction: Vector2) -> void:
_cancel_attack()
if Lab.on(&"dash_iframes"):
health.grant_invulnerability(player.params.dash_time + DASH_GUARD_EXTRA) @export_range(0.05, 0.4, 0.005, "suffix:s") var dash_time := 0.16
## ESPERA entre dos dashes, contada desde que EMPIEZA el primero (en el aire no
## hace falta: hay uno por vuelo). No es un detalle: con el dash protegido
## (`dash_iframes`), una espera corta convierte aporrear el botón en ser
## intocable casi todo el tiempo y en la forma más rápida de andar. La regla:
## al menos el doble de lo que dura la protección, para que entre dos dashes
## haya siempre una ventana vulnerable tan larga como la protegida.
@export_range(0.0, 1.0, 0.01, "suffix:s") var dash_cooldown := 0.45 grant_invulnerability() fills the same timer as the i-frames after a hit and keeps the larger value, so a dash never shortens protection you already had.
Quick answers
How long should dash i-frames last?
The length of the dash plus a small margin for the exit: 0.16 s plus 0.05 s, so 0.21 s here.
Does a dodge dash protect you from spikes?
Not here, and Hollow Knight's Shade Cloak doesn't either. The dodge is for attacks, things that come at you with a warning.
Discussion
Comments are hosted on GitHub Discussions — sign in with GitHub to reply.