UI Overlap Issues
Scenario: The HUD looks fine on a 1920×1080 display, but on 2560×1440 and mobile (portrait), the health bar overlaps the minimap and parts of the HUD go off-screen. Godot's anchor/margin system should handle this, but the configuration is wrong.
Setup
UI/HUD:CanvasLayer→Control(fills screen)UI/HUD/HealthBar:TextureProgressBar— should be bottom-left, 10px from edgesUI/HUD/Minimap:SubViewportContainer— should be bottom-right, 10px from edgesUI/HUD/AmmoLabel:Label— should be bottom-center
Step 1: Configure Spectator to track UI nodes
By default, Spectator excludes UI nodes. Add them to the tracked types:
json
{
"op": "spatial_config",
"extra_tracked_types": ["Control", "TextureProgressBar", "SubViewportContainer", "Label"]
}Step 2: Get a snapshot of the UI layout
Step 3: Check the anchor configuration
Step 4: Fix the anchors
Step 5: Verify at multiple resolutions
Godot anchor system reference
anchor_left=0, anchor_right=0 → pinned to left edge (x = offset_left)
anchor_left=1, anchor_right=1 → pinned to right edge (x = screen_width + offset_left)
anchor_left=0, anchor_right=1 → stretches full width (width = screen_width + offset_right - offset_left)
anchor_left=0.5, anchor_right=0.5 → centered (x = screen_width/2 + offset_left)
anchor_top=0, anchor_bottom=0 → pinned to top (y = offset_top)
anchor_top=1, anchor_bottom=1 → pinned to bottom (y = screen_height + offset_top)
anchor_top=0, anchor_bottom=1 → stretches full height
anchor_top=0.5, anchor_bottom=0.5 → centered verticallyFor bottom-edge anchoring with 10px margin from the bottom:
anchor_top = 1.0, anchor_bottom = 1.0offset_bottom = -10(10px from bottom)offset_top = -50(element is 40px tall + 10px from bottom)
Key takeaways
- Configure Spectator to track UI types — they are excluded by default. Add them to
extra_tracked_typesfor UI debugging sessions. - UI positions from
spatial_snapshotare pixel coordinates in screen space. Compare them against screen resolution to spot off-screen elements. - Hardcoded pixel offsets from top-left are the root cause of most HUD resolution bugs. The fix is always anchors + margin offsets, not hardcoded positions.
- Verify at multiple resolutions by changing the game window size and taking fresh snapshots.