NS-23: fix false arrival when leaving bump tops

VERT_ARRIVE_EPS (0.16) was larger than the bump rise (~0.12–0.15), so a
floor click beside the plateau often satisfied arrival (horiz + vert) on
the first frame and cleared the walk goal before any motion.

Tighten vertical arrival to 0.055. Add a steer fallback when the target
shares xz but is lower (plateau vs floor underfoot) so we still pick a
horizontal escape toward the rim.
pull/23/head
VinPropane 2026-04-05 01:01:22 -04:00
parent 7ffcf54d80
commit 4b9e30c624
1 changed files with 9 additions and 1 deletions

View File

@ -5,7 +5,9 @@ extends CharacterBody3D
const MOVE_SPEED: float = 5.0 const MOVE_SPEED: float = 5.0
const ARRIVE_EPS: float = 0.35 const ARRIVE_EPS: float = 0.35
const VERT_ARRIVE_EPS: float = 0.16 ## Must be **below** NS-19 bump rise (~0.120.15) or we "arrive" while still on the plateau when the
## goal is on the floor beside the bump (small horiz offset + ~0.15 m vertical).
const VERT_ARRIVE_EPS: float = 0.055
const MAX_CLIMB_SPEED: float = 2.6 const MAX_CLIMB_SPEED: float = 2.6
const MAX_DESCENT_SPEED: float = 2.2 const MAX_DESCENT_SPEED: float = 2.2
const DIRECT_APPROACH_RADIUS: float = 0.85 const DIRECT_APPROACH_RADIUS: float = 0.85
@ -57,6 +59,12 @@ func _steer_toward_world_point(point: Vector3) -> void:
var desired: Vector3 = delta.normalized() * MOVE_SPEED var desired: Vector3 = delta.normalized() * MOVE_SPEED
desired.y = clampf(desired.y, -MAX_DESCENT_SPEED, MAX_CLIMB_SPEED) desired.y = clampf(desired.y, -MAX_DESCENT_SPEED, MAX_CLIMB_SPEED)
velocity = desired velocity = desired
elif dy < -0.04:
# Goal is lower and almost same xz (e.g. floor under the plateau): still need rim escape.
var escape_h := Vector3(-global_transform.basis.z.x, 0.0, -global_transform.basis.z.z)
if escape_h.length_squared() < 1e-8:
escape_h = Vector3(1.0, 0.0, 0.0)
velocity = escape_h.normalized() * MOVE_SPEED
else: else:
velocity = Vector3.ZERO velocity = Vector3.ZERO