W1: Third-person character controller and camera

Simulation (src/sim/):
- SimGround holds the terrain heightfield (bilinear heights, normals)
  and axis-aligned box solids, with support, body-overlap, point and
  ray queries. The island generator and building will fill it.
- Movement steps a player per tick: walk, sprint (forward only),
  crouch (lower body, slower, no jump), jump with exact constant-gravity
  integration, air control, step-up onto ledges up to STEP_HEIGHT,
  ground snapping on downhill walks, slopes over MAX_SLOPE_DEGREES that
  block walking and jumping uphill and make players slide (speed capped),
  ceiling bumps, sliding along walls, and fall damage from impact speed.
- Gravity now applies on ticks with no command. on_ground and crouching
  are part of the state hash. New movement numbers are in Tuning.
- Fixed the strafe direction: right is forward x up in Godot's frame,
  (-cos yaw, 0, sin yaw). Documented the look convention.

Client (src/client/):
- CameraRig places an over-the-shoulder camera with an eased
  aim-down-sights blend (closer, narrower FOV), casting against the same
  SimGround: pivot to shoulder, shoulder back, then a straight line from
  the pivot, with a final clearance pull-in so the near plane never
  enters geometry.
- InputSettings: mouse sensitivity, aim sensitivity scale and invert-Y,
  clamped and saved to user://settings.cfg. PlayerCamera applies both.

Tests: 46 new across movement, ground queries, camera and settings,
including a 24,480-view scripted camera sweep through five arenas (wall,
corridor, low roof, corner, steep bank) that checks the eye and every
near-plane corner stay out of geometry with a clear line to the pivot.
The hash test now flips a high stick bit, because a 1/127 nudge to an
airborne player moves them less than the hash's millimetre.
Capture scenarios camera, camera_wall and camera_aim.

Closes #8

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 20:24:02 -05:00
co-authored by Claude Opus 5.5
parent 68635d5fba
commit 70e88cec8a
29 changed files with 1213 additions and 23 deletions
+18
View File
@@ -30,6 +30,24 @@ const SWIM_SPEED: float = 2.0
const CROUCH_SPEED: float = 2.0
const JUMP_VELOCITY: float = 7.5
const GRAVITY: float = 20.0
## Fraction of the gap between current and wanted horizontal velocity closed per tick
## while airborne.
const AIR_CONTROL: float = 0.08
## Ledges up to this height are stepped onto without jumping.
const STEP_HEIGHT: float = 0.45
## Walking keeps the feet on ground that drops away by up to this much per tick.
const GROUND_SNAP: float = 0.35
## Steeper ground can't be walked up or stood on; players slide down it.
const MAX_SLOPE_DEGREES: float = 46.0
## Top speed sliding down ground too steep to stand on.
const SLIDE_MAX_SPEED: float = 8.0
const PLAYER_RADIUS: float = 0.4
const PLAYER_HEIGHT: float = 1.8
const CROUCH_HEIGHT: float = 1.2
## Landing from a drop of this many metres or less does no damage. Measured from impact
## speed, so sliding down a slope is gentler than falling the same height.
const FALL_DAMAGE_SAFE_METRES: float = 6.0
const FALL_DAMAGE_PER_METRE: float = 8.0
# The tide. `hold` and `rise` are seconds, `level` is metres above the starting sea,
# `drown_dps` is damage per second underwater once breath runs out. The last level