From 485553df3e8cc4e70f4c1361c8200f4e71db2867 Mon Sep 17 00:00:00 2001 From: SnekInAScarf Date: Sat, 31 Oct 2026 12:30:08 -0700 Subject: [PATCH] Fix climbing from a ceiling lip onto the wall above - Pressing up while hanging on a lip now moves the slime up and back towards the platform so it wraps onto the wall instead of staying frozen. - Only walking off a ceiling edge starts a lip hang (not landing on a ceiling or dropping off it with down). - Don't count the held direction towards unsticking from the wall right after climbing on from a lip, until it's released. - Remove leftover debug print. Co-Authored-By: Claude Opus 5.5 --- Characters/player.gd | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Characters/player.gd b/Characters/player.gd index b104792..3339703 100755 --- a/Characters/player.gd +++ b/Characters/player.gd @@ -24,6 +24,10 @@ var timeSpentUnstickingCeiling = 0.0 var isClimbingLip = false var timeSpentUnstickingLip= 0.0 +var lipDirection := 0.0 # Which way we were moving when we went over the lip. +# After climbing onto a wall from a lip we're usually still holding away from it, +# so don't count that towards unsticking until the direction is released. +var ignoreWallUnstickUntilRelease := false func _process(delta: float) -> void: # Update sprite to be on the wall or ceiling. In a corner only one of them @@ -57,9 +61,9 @@ func _physics_process(delta: float) -> void: # Move up and down along a wall when sticking to it. elif isStickingToWall: velocity.y = CLIMB_SPEED * verticalInput - # Don't fall if climbing lip. + # Don't fall if climbing lip. Pressing up climbs onto the wall above. elif isClimbingLip: - velocity.y = 0 + velocity.y = CLIMB_SPEED if verticalInput > 0 else 0.0 # Else... just fall. elif not is_on_floor(): velocity.y += get_gravity().y * delta @@ -68,7 +72,8 @@ func _physics_process(delta: float) -> void: # If sticking to a wall, pressing away from it long enough gets us unstuck. if isStickingToWall and not is_on_floor(): var pressingAwayFromWall := horizontalInput * wallNormalX > 0 - if pressingAwayFromWall: timeSpentUnstickingWall += delta + if not pressingAwayFromWall: ignoreWallUnstickUntilRelease = false + if pressingAwayFromWall and not ignoreWallUnstickUntilRelease: timeSpentUnstickingWall += delta else: timeSpentUnstickingWall = 0.0 if timeSpentUnstickingWall >= MAX_SECS_TO_UNSTICK: velocity.x = horizontalInput * GROUND_SPEED @@ -77,9 +82,10 @@ func _physics_process(delta: float) -> void: # Otherwise move horizontally based on what we're on. else: timeSpentUnstickingWall = 0.0 + # Hang on the lip. Pressing up pushes back towards the platform so we + # slide around the corner and touch the wall. if isClimbingLip: - velocity.x = move_toward(velocity.x, 0, GROUND_SPEED) - print(velocity.x) + velocity.x = -lipDirection * WALL_STICK_SPEED if verticalInput > 0 else 0.0 elif horizontalInput and (is_on_floor() or isStickingToCeiling): velocity.x = horizontalInput * GROUND_SPEED elif horizontalInput and not (is_on_floor() or isStickingToCeiling): @@ -103,8 +109,15 @@ func _physics_process(delta: float) -> void: else: timeSpentUnstickingLip = 0.0 var wasJustOnCeiling = isStickingToCeiling isStickingToCeiling = is_on_ceiling() - if (wasJustOnCeiling != isStickingToCeiling) and not isStickingToWall: + # Only walking off the ceiling's edge counts as a lip, not landing on + # a ceiling or letting go of it by pressing down. + if wasJustOnCeiling and not isStickingToCeiling and not isStickingToWall and velocity.x: isClimbingLip = true + lipDirection = signf(velocity.x) + # Made it onto the wall from the lip. + if isClimbingLip and isStickingToWall: + isClimbingLip = false + ignoreWallUnstickUntilRelease = true # In a corner touching both wall and ceiling, only stick to one # surface depending on if we're pressing into the ceiling or not. -- 2.45.2