Quick answer: Anchors only work when the parent is a plain Control (or root Viewport). Container parents override child anchors. Set anchors_preset to Full Rect on the child, ensure the parent is a Control, and pick a project Stretch Mode that matches your design.
Here is how to fix Godot Control nodes whose anchors do not adjust when the window changes size. Your HUD looks correct at the design resolution but cuts off in the corner at any other size. Either the anchors are wrong, or a Container parent is overriding them, or the project’s viewport stretch mode is fighting your layout.
The Symptom
Drag the window edge to resize. The HUD does not adjust — it stays anchored to the top-left, leaving the rest of the window blank or showing scaled-up content. Or the entire UI compresses uniformly while you wanted only certain elements to stretch.
What Causes This
Anchors not full rect. Default anchors are 0,0 (single point at top-left). The control sits there and never resizes. Set Full Rect for stretch behavior.
Container parent overrides anchors. If a Control is inside an HBoxContainer, VBoxContainer, GridContainer, etc., the Container sets the child’s position and size each frame. Anchors are ignored.
Wrong stretch mode. Project Settings → Display → Window → Stretch determines how the viewport handles window size changes. Mode = viewport scales the whole UI; mode = disabled lets anchors handle it.
Custom minimum size pinning. If a control has a large custom_minimum_size, it cannot shrink, regardless of anchors.
The Fix
Step 1: Set anchors via the editor preset. Select the Control. In the toolbar, click Anchors and pick Full Rect (or Wide Rect, Top Right, etc., depending on intent). The anchors update to match.
Step 2: Pick the right Container vs Control parent.
# For a HUD that resizes with window:
Root (CanvasLayer)
HUD (Control) # Full Rect anchors
HealthBar (TextureProgress) # Anchored top-left
Minimap (Sprite2D) # Anchored top-right
# For a list of items:
Root (CanvasLayer)
Inventory (VBoxContainer) # Container manages children
Item1 (Button)
Item2 (Button)
Use Containers for laid-out groups (lists, grids). Use plain Control for hand-placed elements that should anchor to viewport edges.
Step 3: Configure project Stretch Mode.
# Project Settings -> Display -> Window -> Stretch
Mode = canvas_items # Recommended for most 2D games
Aspect = keep # Maintain aspect ratio
Scale = 1.0
canvas_items mode renders 2D content at the actual window resolution while maintaining the design viewport coordinates. Anchors then stretch to match the actual window. For pixel-art games, prefer viewport mode with a low base resolution.
Step 4: Watch for custom_minimum_size. If the control will not shrink below a value, that is your minimum size. Reset to 0 unless you have a specific minimum.
Step 5: Connect to size_changed for runtime tweaks.
extends Control
func _ready():
get_viewport().size_changed.connect(_on_window_resized)
func _on_window_resized():
# Custom adjustments not handled by anchors
$Sidebar.custom_minimum_size.x = get_viewport_rect().size.x * 0.2
Common Layout Patterns
Top bar: anchors_preset = Top Wide. Stretches across the top, fixed height.
Bottom HUD: anchors_preset = Bottom Wide. Stretches across the bottom.
Centered modal: anchors_preset = Center. Stays centered as window resizes.
Sidebar: anchors_preset = Right Wide or Left Wide. Stretches vertically, fixed width.
“Anchors describe how a Control follows its parent. Containers override anchors. Pick the right tool for each part of the UI.”
Related Issues
For CanvasLayer behavior, see CanvasLayer Follow Viewport. For Camera2D smoothing, see Camera2D Smoothing Jitter.
Anchors preset for stretch. Control parent for anchors to work. canvas_items for most projects.