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:
+10
-1
@@ -19,7 +19,16 @@ const BULLET_CULL_MARGIN := 64.0
|
||||
|
||||
# --- Player -----------------------------------------------------------------
|
||||
const PLAYER_SPEED := 240.0
|
||||
const PLAYER_RADIUS := 9.0
|
||||
## Authoritative hitbox. Smaller than PLAYER_VISUAL_RADIUS on purpose: a client
|
||||
## renders its own and everyone else's ship a little late (interpolation delay,
|
||||
## reconciliation smoothing), so a hitbox that matched the sprite exactly would
|
||||
## let bullets connect against a ship the player watched dodge clear of them.
|
||||
## Erring small means the occasional bullet visibly clips the ship without a
|
||||
## hit -- a client-side illusion, but the one that reads as fair, versus a
|
||||
## bullet that visibly missed still registering as a hit.
|
||||
const PLAYER_RADIUS := 6.0
|
||||
## Render-only. Used by src/view/, never by anything under src/sim/.
|
||||
const PLAYER_VISUAL_RADIUS := 13.0
|
||||
const PLAYER_MAX_HP := 100
|
||||
const PLAYER_FIRE_COOLDOWN := 7 # ticks
|
||||
const PLAYER_BULLET_SPEED := 620.0
|
||||
|
||||
Reference in New Issue
Block a user