From 4df71ac0ccc32fefafe839017541ffbf4519d69e Mon Sep 17 00:00:00 2001 From: VinPropane Date: Sun, 12 Apr 2026 01:03:40 -0400 Subject: [PATCH] NEON-29: Fix floor walk stall from tight nav agent distances. Revert path_desired_distance and target_desired_distance to 0.35; 0.22 was below practical per-tick progress toward waypoints and led to oscillation or stuck path state. When NavigationAgent reports finished but horizontal distance still exceeds ARRIVE_EPS, steer directly toward the authoritative goal in XZ. --- client/scenes/main.tscn | 4 ++-- client/scripts/player.gd | 26 ++++++++++++++--------- docs/plans/NEON-29-implementation-plan.md | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/client/scenes/main.tscn b/client/scenes/main.tscn index dade6d9..9edf7ff 100644 --- a/client/scenes/main.tscn +++ b/client/scenes/main.tscn @@ -480,8 +480,8 @@ script = ExtResource("2_player") shape = SubResource("CapsuleShape3D_player") [node name="NavigationAgent3D" type="NavigationAgent3D" parent="World/Player" unique_id=8880002] -path_desired_distance = 0.22 -target_desired_distance = 0.22 +path_desired_distance = 0.35 +target_desired_distance = 0.35 radius = 0.4 [node name="MeshInstance3D" type="MeshInstance3D" parent="World/Player" unique_id=2027034386] diff --git a/client/scripts/player.gd b/client/scripts/player.gd index 5a1f27e..9a29609 100644 --- a/client/scripts/player.gd +++ b/client/scripts/player.gd @@ -687,17 +687,23 @@ func _physics_process(delta: float) -> void: else: _set_horizontal_velocity_from_nav_path_or_goal(want_goal_h) else: - var next_path_position: Vector3 = _nav_agent.get_next_path_position() - var to_next_h: Vector3 = Vector3( - next_path_position.x - global_position.x, 0.0, next_path_position.z - global_position.z - ) - # When the next mesh point is almost under the capsule (same XZ), still steer using the - # segment from agent to next point if it has length; else fall back to full goal direction - # (not arbitrary +X) so vertical-offset goals and nav edges resolve. - if to_next_h.length_squared() > 0.0025: - _set_horizontal_velocity_toward(next_path_position, want_goal_h) - else: + # Tight path_desired_distance can make the agent oscillate around a corner without ever + # satisfying the advance threshold; finished-with-no-path can also happen if the map was + # empty or the target projected oddly. In those cases keep bee-lining in XZ toward the goal. + if _nav_agent.is_navigation_finished() and horiz_dist > ARRIVE_EPS: _set_horizontal_velocity_toward(_auth_walk_goal, want_goal_h) + else: + var next_path_position: Vector3 = _nav_agent.get_next_path_position() + var to_next_h: Vector3 = Vector3( + next_path_position.x - global_position.x, 0.0, next_path_position.z - global_position.z + ) + # When the next mesh point is almost under the capsule (same XZ), still steer using the + # segment from agent to next point if it has length; else fall back to full goal direction + # (not arbitrary +X) so vertical-offset goals and nav edges resolve. + if to_next_h.length_squared() > 0.0025: + _set_horizontal_velocity_toward(next_path_position, want_goal_h) + else: + _set_horizontal_velocity_toward(_auth_walk_goal, want_goal_h) _apply_walk_air_gravity(delta) floor_snap_length = _walk_floor_snap_length(feet_y, want_goal_h) diff --git a/docs/plans/NEON-29-implementation-plan.md b/docs/plans/NEON-29-implementation-plan.md index 6bbb50f..242b3fe 100644 --- a/docs/plans/NEON-29-implementation-plan.md +++ b/docs/plans/NEON-29-implementation-plan.md @@ -113,7 +113,7 @@ No new automated GDScript tests are added for this story — there is no new GDS - **Lip stuck (floor→platform / platform→floor):** QA screenshots for this were on **`TerracePlatformA`** (10 × 10 large SE pad, **0.3 m** single step — not the NW **Terrace B** step/platform pair). Step assist required **`vel_h.dot(want) ≤ 0.52`**, so a **head-on** push into the vertical face (dot ≈ 1) **never** triggered the lift. **Removed** that gate. For **platform→floor**, **`floor_block_on_wall = false`** only when the nav goal is **below** the feet **and** **`is_on_wall()`** or a **wall-ish slide normal** exists, so open deck walking stays stable. - **Teal pad still stuck (follow-up):** Step assist used **slide normals only**; Jolt often exposes the lip via **`is_on_wall()`** / **`get_wall_normal()`** instead — re-added a **directional** wall check (`wnh.dot(want) < -0.02`). Descend relax now also triggers on **shallow floor normal** (`get_floor_normal().dot(UP) < 0.992`) and slightly wider vertical-ish slide band. **`TerracePlatformA`** root **Y = 0.012 m** breaks **coplanarity** with the main floor without the larger gap that hurt **TerraceStepB** approach. - **Teal cardinal / tread shake (rollback):** Aggressive tweaks (**0.16** lift, **1**-tick cooldown, **`descending_stall`** toggling **`floor_block_on_wall`**, **seam-based** step-assist clear, **walk-stall nav replan**) caused **oscillation** on the small approach treads. **Reverted** to **`WALK_STEP_ASSIST_DELTA = 0.11`**, **`WALK_STEP_ASSIST_COOLDOWN_TICKS = 8`**, **no** stall replan, **no** `descending_stall` branch, **no** seam-based assist clear — only the original clear (clean floor without wall, or airborne with no slides). **Climb** wallish snap cap applies only when **`goal.y > feet_y + 0.12`** so shallow tread-to-tread motion is not capped to assist snap every frame. -- **Teal pad — geometry wins:** Script-only mitigations still failed in practice; **`TerracePlatformA_Approach`** adds **twelve** `walkable` **`StaticBody3D`** treads (three per cardinal) with **~0.104 m** rise each, **darker teal** albedo, flush to the platform lip — nav + `CharacterBody3D` use **sloped contact** instead of fighting a **single vertical face**. **Follow-up:** tread **run** was **0.45 m** along the climb axis while the capsule **diameter is 0.8 m** — the body was wider than each tread, causing straddle / stuck motion when **entering** and blocking horizontal progress toward the lip when **exiting**. Treads widened to **1.0 m** run with positions re-centered; **`NavigationAgent3D`** `path_desired_distance` / `target_desired_distance` tightened **0.35 → 0.22** so path corners are not released while still far from the stair entry. +- **Teal pad — geometry wins:** Script-only mitigations still failed in practice; **`TerracePlatformA_Approach`** adds **twelve** `walkable` **`StaticBody3D`** treads (three per cardinal) with **~0.104 m** rise each, **darker teal** albedo, flush to the platform lip — nav + `CharacterBody3D` use **sloped contact** instead of fighting a **single vertical face**. **Follow-up:** tread **run** was **0.45 m** along the climb axis while the capsule **diameter is 0.8 m** — the body was wider than each tread, causing straddle / stuck motion when **entering** and blocking horizontal progress toward the lip when **exiting**. Treads widened to **1.0 m** run with positions re-centered. **`NavigationAgent3D`** `path_desired_distance` / `target_desired_distance` were briefly lowered to **0.22** but that caused **floor** movement to **stall** (waypoint threshold tighter than practical motion at `MOVE_SPEED` / physics dt, plus finished-without-arrival edge cases); **reverted to 0.35** and **`player.gd`** now **bee-lines in XZ** when **`is_navigation_finished()`** yet **`horiz_dist > ARRIVE_EPS`**. ## Open questions / risks