From f167c74204c9941a83c5ba2954de93df2b8c766e Mon Sep 17 00:00:00 2001 From: SnekInAScarf Date: Sat, 31 Oct 2026 17:31:14 -0700 Subject: [PATCH] Only let go of walls and ceilings when not moving along them Holding away from a wall while climbing, or down on a ceiling while moving left/right, no longer counts towards MAX_SECS_TO_UNSTICK; the timer starts over once you stop. Same rule as the floor hop, and it covers both letting go and hopping across. Co-Authored-By: Claude Opus 5.5 --- Characters/player.gd | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Characters/player.gd b/Characters/player.gd index 8b6c7ef..69774ca 100755 --- a/Characters/player.gd +++ b/Characters/player.gd @@ -43,8 +43,9 @@ const MAX_SECS_TO_UNSTICK = 0.5 # Hop: holding up (and not left/right) on the floor for MAX_SECS_TO_UNSTICK hops just high enough # to reach a ceiling up to HOP_MAX_HEIGHT above us (measured from our top). # With no ceiling in reach it's just a little HOP_NO_CEILING_HEIGHT hop. -# Walls and ceilings work the same way with the direction away from them, but -# with nothing in reach we let go as usual instead of doing a little hop. +# Walls and ceilings work the same way with the direction away from them (also +# only while not moving along them), but with nothing in reach we let go as +# usual instead of doing a little hop. const HOP_MAX_HEIGHT = 32.0 const HOP_NO_CEILING_HEIGHT = 16.0 const HOP_OVERSHOOT = 2.0 # Aim slightly past the ceiling so we still hit it with some speed. @@ -155,15 +156,16 @@ func _physics_process(delta: float) -> void: # Vertical Input Controls if isStickingToCeiling: - # If on ceiling, pressing down long enough unsticks from ceiling. + # If on ceiling, pressing down long enough (while not moving along it) + # unsticks from ceiling. if verticalInput >= 0: ignoreCeilingUnstickUntilRelease = false - if verticalInput < 0 and not ignoreCeilingUnstickUntilRelease: timeSpentUnstickingCeiling += delta + if verticalInput < 0 and not horizontalInput and not ignoreCeilingUnstickUntilRelease: + timeSpentUnstickingCeiling += delta else: timeSpentUnstickingCeiling = 0.0 if timeSpentUnstickingCeiling >= MAX_SECS_TO_UNSTICK: isStickingToCeiling = false - # Standing still with a floor within reach below: hop down onto it. - # Otherwise just let go. - var floorDistance := -1.0 if horizontalInput else _get_hop_distance(Vector2.DOWN) + # With a floor within reach below: hop down onto it. Otherwise just let go. + var floorDistance := _get_hop_distance(Vector2.DOWN) if floorDistance >= 0.0: velocity.y = sqrt(2.0 * get_gravity().y * floorDistance) else: velocity.y = get_gravity().y * delta else: velocity.y = CEILING_STICK_SPEED @@ -187,16 +189,17 @@ func _physics_process(delta: float) -> void: velocity.y = -sqrt(2.0 * get_gravity().y * _get_hop_height()) # Horizontal Input Controls - # If sticking to a wall, pressing away from it long enough gets us unstuck. + # If sticking to a wall, pressing away from it long enough (while not + # climbing) gets us unstuck. if isStickingToWall and not is_on_floor(): var pressingAwayFromWall := horizontalInput * wallNormalX > 0 if not pressingAwayFromWall: ignoreWallUnstickUntilRelease = false - if pressingAwayFromWall and not ignoreWallUnstickUntilRelease: timeSpentUnstickingWall += delta + if pressingAwayFromWall and not verticalInput and not ignoreWallUnstickUntilRelease: + timeSpentUnstickingWall += delta else: timeSpentUnstickingWall = 0.0 if timeSpentUnstickingWall >= MAX_SECS_TO_UNSTICK: - # Not climbing, with a wall within reach opposite: hop across to it. - # Otherwise just let go. - var wallDistance := -1.0 if verticalInput else _get_hop_distance(Vector2(wallNormalX, 0)) + # With a wall within reach opposite: hop across to it. Otherwise just let go. + var wallDistance := _get_hop_distance(Vector2(wallNormalX, 0)) if wallDistance >= 0.0: _hop_across(wallDistance) else: velocity.x = horizontalInput * GROUND_SPEED else: