Hit Freeze
Part of the Game Feel section of Coddy's Godot journey. Lesson 17 of 23.
A hit freeze stops the game for a split second when a hit lands. It makes the hit feel strong.
Engine.time_scale is the speed of the game's clock. At 1 the game runs normally. At 0.05, movement, tweens and timers run twenty times slower.
Engine.time_scale = 0.05
await get_tree().create_timer(0.1, true, false, true).timeout
Engine.time_scale = 1.0A normal timer runs on the slowed clock, so 0.1 seconds would last two real seconds. The last true in create_timer makes the timer ignore time_scale and count real seconds. The two values before it are the usual defaults.
Always set time_scale back to 1. It affects the whole game and stays until your code changes it.
Challenge
MediumAfter the flash in hit(), freeze the game. Set Engine.time_scale to 0.05, wait 0.1 real seconds with a timer that ignores the time scale, then set it back to 1.0. Press E and watch the drone stop.
Try it yourself
extends Node2D
func hit():
modulate = Color(4, 4, 4)
var tween = create_tween()
tween.tween_property(self, "modulate", Color(1, 1, 1), 0.3)
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Game Feel
Practice on your own: Godot playground