Fix lobby/HUD UI pinned at (0,0); shrink player hitbox below visual size
ci / verify (push) Successful in 45s
ci / verify (push) Successful in 45s
The lobby connect menu and three pieces of the HUD (hit-flash overlay, boss bar centering, death-message centering, hint label) were all silently broken by the same Godot gotcha: set_anchors_preset(preset) with the default keep_offsets=false does NOT zero the offsets to the preset's margins -- it recomputes them to preserve the control's *current* rect, which for a freshly constructed Control is (0,0). Anchors end up correct; the actual rect stays pinned to the top-left corner regardless. Fixed by switching to set_anchors_and_offsets_preset() everywhere a Control is built in code, and by using offset_left/offset_top (anchor-relative) instead of .position (absolute) for the HUD hint label. Documented as gotcha #5 in CLAUDE.md. Also split PLAYER_RADIUS into two constants: PLAYER_RADIUS (6.0, the authoritative hitbox used by SimWorld) and PLAYER_VISUAL_RADIUS (13.0, view-only, used by world_view.gd). The client renders every ship a little late relative to the server -- interpolation delay, reconciliation smoothing -- so a hitbox that matched the sprite would let bullets connect against a ship the player watched dodge clear of them. A smaller hitbox means the occasional bullet visibly clips the sprite without a hit, which reads as more forgiving of latency than the reverse. Verified headlessly: a throwaway scene instantiating MainMenu/HUD under a real 1280x720 viewport, asserting the panel is centered and _canvas.size / hint position resolve correctly, before and after each fix. check.sh, test.sh (78/78) and smoke.sh all pass.
This commit is contained in:
@@ -87,7 +87,16 @@ ticks in milliseconds with no SceneTree.
|
||||
4. **Input events default to `device = 16`, which matches nothing.** Bindings
|
||||
must use `device = -1`. `tools/setup_input_map.gd` generates the input map
|
||||
correctly; edit that file, not the `[input]` block in `project.godot`.
|
||||
5. **`ProjectSettings.save()` drops settings equal to the engine default** and
|
||||
5. **`set_anchors_preset(preset)` does not zero the offsets.** `keep_offsets`
|
||||
defaults to `false`, which despite the name means "recompute offsets to keep
|
||||
the control's *current* rect on screen" — for a freshly created Control that
|
||||
rect is `(0,0)`-sized, so it comes out pinned to the top-left corner
|
||||
regardless of the anchors. Use `set_anchors_and_offsets_preset()` for any
|
||||
Control built in code. Separately: `.position` assigns an *absolute*
|
||||
coordinate even on an anchored control; `offset_left`/`offset_top` are the
|
||||
anchor-relative ones. This combination silently broke the main menu and
|
||||
three pieces of the HUD.
|
||||
6. **`ProjectSettings.save()` drops settings equal to the engine default** and
|
||||
strips comments. Anything load-bearing (the 60 Hz tick) is asserted in code
|
||||
in `src/main.gd` instead of trusted to `project.godot`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user