diff --git a/client/scripts/player.gd b/client/scripts/player.gd index 057f2ad..61a329a 100644 --- a/client/scripts/player.gd +++ b/client/scripts/player.gd @@ -24,8 +24,8 @@ const NAV_COLUMN_STEER_ENTER_DIST: float = 0.74 const NAV_COLUMN_STEER_EXIT_DIST: float = 0.97 ## First path waypoint used for column steer must be at least this far in XZ. [method NavigationAgent3D.get_next_path_position] ## can sit ~4 cm from the capsule; Jolt slides ~4 cm/tick → the “toward next” vector flips 180° every frame -## (`vlat && ncol` NEON-16 traces). A 22 cm gate matches foot-scale probes and stays stable on treads. -const NAV_PATH_STEER_MIN_LOOKAHEAD: float = 0.22 +## (`vlat && ncol` NEON-16 traces). ~28 cm reduces waypoint flip on treads without starving short segments. +const NAV_PATH_STEER_MIN_LOOKAHEAD: float = 0.28 ## If lookahead steering points more than ~105° from the click direction (XZ), use direct goal steer instead. const NAV_PATH_STEER_MIN_GOAL_DOT: float = -0.25 ## While [code]vlat && ncol[/code], ledge peel + zero floor snap fight [method move_and_slide] on approach treads @@ -38,6 +38,11 @@ const WALK_PEEL_SUSPEND_VERT_SEP: float = 0.48 ## so shallow lips (~0.48 m) still peel; widened from 0.34 to cover ~0.35–0.47 m stair/goal gaps. const WALK_PEEL_SUSPEND_HORIZ_VERT_SEP: float = 0.46 const WALK_PEEL_SUSPEND_HORIZ_DIST: float = 5.0 +## On-floor only: cap horizontal speed in [method _walk_tread_jitter_damp_active] so full [member MOVE_SPEED] +## does not hammer stair risers after peel/snap debounce (still ~mm–cm Y noise at y≈1.09). +const WALK_TREAD_STABILITY_MAX_HORIZ_SPEED: float = 1.35 +## With [code]vlat[/code] false, only damp when this close in XZ — avoids slowing long same-level approaches. +const WALK_TREAD_STABILITY_DAMP_HORIZ_DIST: float = 1.05 ## [method _walk_has_close_floor_probe_below] often flips on stairs: next tread is ~0.104 m down but ## [member WALK_CONTINUATION_MAX_BELOW_FEET] is 0.078 m, so rays reject the hit → peel + zero snap ## alternate with full snap each tick (~y≈1.0 jitter). Require this many consecutive probe-fail frames @@ -496,6 +501,25 @@ func _walk_peel_suspend_near_goal(feet_y: float, horiz_dist: float) -> bool: return vsep <= WALK_PEEL_SUSPEND_HORIZ_VERT_SEP and horiz_dist <= WALK_PEEL_SUSPEND_HORIZ_DIST +func _walk_tread_jitter_damp_active(feet_y: float, horiz_dist: float) -> bool: + if not _has_walk_goal or not is_on_floor(): + return false + var vsep: float = absf(_auth_walk_goal.y - feet_y) + if _walk_vert_route_latched and _walk_nav_column_steering and vsep < WALK_PEEL_SUSPEND_VERT_SEP: + return true + return vsep <= WALK_PEEL_SUSPEND_HORIZ_VERT_SEP and horiz_dist <= WALK_TREAD_STABILITY_DAMP_HORIZ_DIST + + +func _walk_apply_tread_horizontal_speed_cap() -> void: + var vxz := Vector2(velocity.x, velocity.z) + var sp: float = vxz.length() + if sp <= WALK_TREAD_STABILITY_MAX_HORIZ_SPEED + 1e-6: + return + var scale: float = WALK_TREAD_STABILITY_MAX_HORIZ_SPEED / sp + velocity.x = vxz.x * scale + velocity.z = vxz.y * scale + + func _walk_refresh_ledge_peel_debounce(feet_y: float, move_dir_xz: Vector2) -> void: var probe_ok: bool = _walk_has_close_floor_probe_below(move_dir_xz) var deep: bool = feet_y > _auth_walk_goal.y + WALK_DEEP_DESCENT_FEET_ABOVE_GOAL @@ -1099,6 +1123,9 @@ func _physics_process(delta: float) -> void: else: _set_horizontal_velocity_toward(_auth_walk_goal, want_goal_h) + if _walk_tread_jitter_damp_active(feet_y, horiz_dist): + _walk_apply_tread_horizontal_speed_cap() + var walk_move_dir_xz: Vector2 = _resolve_walk_probe_dir_xz(feet_y, want_goal_h) _walk_refresh_ledge_peel_debounce(feet_y, walk_move_dir_xz)