diff --git a/client/scripts/player.gd b/client/scripts/player.gd index e69497a..0cacc9b 100644 --- a/client/scripts/player.gd +++ b/client/scripts/player.gd @@ -250,9 +250,28 @@ func _set_horizontal_velocity_toward(point: Vector3, fallback_dir_xz: Vector3 = ## While walking, integrate gravity when airborne so Jolt can register floor contacts and ## `move_and_slide` is not stuck with vy=0 above the surface (expanded district / terraces). func _apply_walk_air_gravity(delta: float) -> void: - if is_on_floor(): + var g_step: Vector3 = get_gravity() * delta + if not is_on_floor(): + velocity += g_step return - velocity += get_gravity() * delta + # Descending toward a lower surface (e.g. first terrace step → main floor): rim / internal + # edge contact can keep `is_on_floor()` true on the upper surface while the step's vertical + # face zeros horizontal motion. With vy forced to 0 by `_set_horizontal_velocity_toward`, + # no gravity ran and the capsule could hang until a new click retargeted. Shallow 0.3 m + # drops hit this more often than taller platform→floor descents. + var feet_on_floor: float = capsule_feet_y(global_position.y, CAPSULE_HALF_HEIGHT + PLAYER_CAPSULE_RADIUS) + var descending: bool = ( + _has_walk_goal and _auth_walk_goal.y < feet_on_floor - DESCEND_GOAL_Y_MARGIN + ) + if descending and g_step.y < 0.0: + var wallish: bool = is_on_wall() + if not wallish: + for i: int in get_slide_collision_count(): + if get_slide_collision(i).get_normal().y < 0.55: + wallish = true + break + if wallish: + velocity.y += g_step.y ## When the authoritative goal shares XZ with the capsule (e.g. terrace above), horizontal