CHALLENGE 3: A Toggleable Pause Menu ==================================================================== TASK ---- Build a Control-based pause menu that starts hidden. Bind a "pause" action to the Escape key in the Input Map, and toggle the menu's visibility each time it's pressed using visible = not visible. SETUP ----- 1. Project > Project Settings > Input Map. 2. Add a "pause" action, click "+", and press the Escape key to bind it. 3. Add a Control node named "PauseMenu" (optionally with a Label child reading "Paused" so there's something visible to confirm against), anchored to Full Rect or Center via the Layout menu. SOLUTION CODE (attached to PauseMenu) -------------------------------------------- extends Control func _ready() -> void: hide() func _process(delta: float) -> void: if Input.is_action_just_pressed("pause"): visible = not visible WHY THIS WORKS AS AN ANSWER ---------------------------- hide() in _ready() is equivalent to setting visible = false at startup - it's the chapter's own convenience method, used here as a slightly more readable way of expressing "start hidden" than writing out the assignment directly, though both do the same thing. Input.is_action_just_pressed("pause") is deliberately used instead of is_action_pressed() (Chapter 5's distinction) - the toggle only needs to fire once per key press, not repeatedly for as long as Escape happens to be held down. Using is_action_pressed() here would make the menu flicker open and closed dozens of times a second while the key was held, since visible = not visible would flip on every single frame it stayed true. visible = not visible is what performs the actual toggle: each time the condition fires, the Control's own visible property flips to the opposite of whatever it currently is - true becomes false, false becomes true - so pressing Escape once opens the menu, and pressing it again closes it, with no separate "is the menu open" variable needed since visible itself already holds that exact information.