From 935ee797dce540b31d96fbdb7c277dee6a2ece8d Mon Sep 17 00:00:00 2001 From: SnekInAScarf Date: Sat, 31 Oct 2026 16:21:31 -0700 Subject: [PATCH 1/5] Hop up to the ceiling after holding up on the floor Holding up on the floor for MAX_SECS_TO_UNSTICK hops just high enough to reach a ceiling up to HOP_MAX_HEIGHT (64px) above the slime's top, where it then sticks. With no ceiling in reach it does a little 16px hop. Against a wall, up still climbs it instead. Co-Authored-By: Claude Opus 5.5 --- Characters/player.gd | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Characters/player.gd b/Characters/player.gd index c166b08..909b65f 100755 --- a/Characters/player.gd +++ b/Characters/player.gd @@ -37,6 +37,14 @@ const MIN_LAND_SPEED = 60.0 # Slower impacts than this don't splat. # How long to press opposite direction before unsticking from a wall/ceiling const MAX_SECS_TO_UNSTICK = 0.5 +# Hop: holding up 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. +const HOP_MAX_HEIGHT = 64.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. +var timeSpentHoldingUpOnFloor := 0.0 + var isStickingToWall := false var timeSpentUnstickingWall = 0.0 @@ -158,6 +166,14 @@ func _physics_process(delta: float) -> void: elif not is_on_floor(): velocity.y = minf(velocity.y + get_gravity().y * delta, MAX_FALL_SPEED) + # On the floor, holding up long enough hops up to the ceiling above. Not + # against a wall though, where up climbs it instead. + if is_on_floor() and not isStickingToWall and verticalInput > 0: timeSpentHoldingUpOnFloor += delta + else: timeSpentHoldingUpOnFloor = 0.0 + if timeSpentHoldingUpOnFloor >= MAX_SECS_TO_UNSTICK: + timeSpentHoldingUpOnFloor = 0.0 + 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 isStickingToWall and not is_on_floor(): @@ -236,6 +252,13 @@ func _physics_process(delta: float) -> void: _update_sprite_rotation(delta) +# How high to hop: up to the ceiling above us if there's one in reach. +func _get_hop_height() -> float: + var hit := move_and_collide(Vector2(0, -HOP_MAX_HEIGHT), true) + if hit and hit.get_normal().y > 0.5: + return hit.get_travel().length() + HOP_OVERSHOOT + return HOP_NO_CEILING_HEIGHT + # Moves speed towards target: GROUND_ACCEL when speeding up, GROUND_FRICTION # when slowing down or stopping. func _accelerate(speed: float, target: float) -> float: -- 2.45.2 From 4b96d21add2d462b6825f3ace5032753e1eb16c2 Mon Sep 17 00:00:00 2001 From: SnekInAScarf Date: Sat, 31 Oct 2026 16:27:44 -0700 Subject: [PATCH 2/5] Only hop when not moving left/right; hop reach is one tile - Holding left or right resets the hop timer, so the 0.5s hold only counts while standing still. - HOP_MAX_HEIGHT is now 32 (one tile), as adjusted by hand. Co-Authored-By: Claude Opus 5.5 --- Characters/player.gd | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Characters/player.gd b/Characters/player.gd index 909b65f..eda47f7 100755 --- a/Characters/player.gd +++ b/Characters/player.gd @@ -37,10 +37,10 @@ const MIN_LAND_SPEED = 60.0 # Slower impacts than this don't splat. # How long to press opposite direction before unsticking from a wall/ceiling const MAX_SECS_TO_UNSTICK = 0.5 -# Hop: holding up on the floor for MAX_SECS_TO_UNSTICK hops just high enough +# 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. -const HOP_MAX_HEIGHT = 64.0 +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. var timeSpentHoldingUpOnFloor := 0.0 @@ -166,9 +166,10 @@ func _physics_process(delta: float) -> void: elif not is_on_floor(): velocity.y = minf(velocity.y + get_gravity().y * delta, MAX_FALL_SPEED) - # On the floor, holding up long enough hops up to the ceiling above. Not - # against a wall though, where up climbs it instead. - if is_on_floor() and not isStickingToWall and verticalInput > 0: timeSpentHoldingUpOnFloor += delta + # On the floor and standing still, holding up long enough hops up to the + # ceiling above. Not against a wall though, where up climbs it instead. + if is_on_floor() and not isStickingToWall and verticalInput > 0 and not horizontalInput: + timeSpentHoldingUpOnFloor += delta else: timeSpentHoldingUpOnFloor = 0.0 if timeSpentHoldingUpOnFloor >= MAX_SECS_TO_UNSTICK: timeSpentHoldingUpOnFloor = 0.0 -- 2.45.2 From e8cf70e6e5cb9b6e96aa74c9c3d18e67bdbeb213 Mon Sep 17 00:00:00 2001 From: SnekInAScarf Date: Sat, 31 Oct 2026 17:16:48 -0700 Subject: [PATCH 3/5] Hop across from walls and ceilings too Holding away from a wall or ceiling for MAX_SECS_TO_UNSTICK, while not moving along it, now hops straight across to a surface within HOP_MAX_HEIGHT on that side and sticks to it. With nothing in reach (or while moving along the surface) it lets go as before. - Wall hops go at crawling speed on an arc that lands at the same height, with no air steering until they land. - Ceiling hops push down onto the floor below. Co-Authored-By: Claude Opus 5.5 --- Characters/player.gd | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/Characters/player.gd b/Characters/player.gd index eda47f7..a39fabb 100755 --- a/Characters/player.gd +++ b/Characters/player.gd @@ -1,5 +1,8 @@ extends CharacterBody2D +# Note: should check if i want unsticking to occur while moving on ceiling or wall. +# so far it isn't the case with ground movement. + const GROUND_SPEED = 150.0 const AIR_SPEED = 75.0 @@ -40,10 +43,13 @@ 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. 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. var timeSpentHoldingUpOnFloor := 0.0 +var isHoppingAcross := false # Hopping from a wall to the one opposite: no air steering until we land. var isStickingToWall := false var timeSpentUnstickingWall = 0.0 @@ -129,6 +135,7 @@ func _physics_process(delta: float) -> void: return var wasInAir := _get_surface_normal() == Vector2.ZERO and not isClimbingLip + if not wasInAir: isHoppingAcross = false # Hanging on a lip and pressing up: swing around onto the wall above. var wantsToClimb := verticalInput > 0 or timeSinceUpPressed <= CLIMB_INPUT_BUFFER @@ -154,7 +161,11 @@ func _physics_process(delta: float) -> void: else: timeSpentUnstickingCeiling = 0.0 if timeSpentUnstickingCeiling >= MAX_SECS_TO_UNSTICK: isStickingToCeiling = false - velocity.y = get_gravity().y * delta + # 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) + 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 # Move up and down along a wall when sticking to it. elif isStickingToWall: @@ -183,7 +194,11 @@ func _physics_process(delta: float) -> void: if pressingAwayFromWall and not ignoreWallUnstickUntilRelease: timeSpentUnstickingWall += delta else: timeSpentUnstickingWall = 0.0 if timeSpentUnstickingWall >= MAX_SECS_TO_UNSTICK: - velocity.x = horizontalInput * GROUND_SPEED + # 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)) + if wallDistance >= 0.0: _hop_across(wallDistance) + else: velocity.x = horizontalInput * GROUND_SPEED else: velocity.x = -wallNormalX * WALL_STICK_SPEED # Otherwise move horizontally based on what we're on. @@ -195,7 +210,7 @@ func _physics_process(delta: float) -> void: velocity.x = -lipDirection * WALL_STICK_SPEED if verticalInput > 0 else 0.0 elif is_on_floor() or isStickingToCeiling: velocity.x = _accelerate(velocity.x, horizontalInput * GROUND_SPEED) - else: + elif not isHoppingAcross: velocity.x = _air_steer(velocity.x, horizontalInput) _hold_at_edge(delta) @@ -255,10 +270,24 @@ func _physics_process(delta: float) -> void: # How high to hop: up to the ceiling above us if there's one in reach. func _get_hop_height() -> float: - var hit := move_and_collide(Vector2(0, -HOP_MAX_HEIGHT), true) - if hit and hit.get_normal().y > 0.5: + var distance := _get_hop_distance(Vector2.UP) + return distance if distance >= 0.0 else HOP_NO_CEILING_HEIGHT + +# How far to hop in direction to reach a surface facing us within +# HOP_MAX_HEIGHT (plus HOP_OVERSHOOT), or -1 if there isn't one. +func _get_hop_distance(direction: Vector2) -> float: + var hit := move_and_collide(direction * HOP_MAX_HEIGHT, true) + if hit and hit.get_normal().dot(-direction) > 0.5: return hit.get_travel().length() + HOP_OVERSHOOT - return HOP_NO_CEILING_HEIGHT + return -1.0 + +# Hops from the wall we're on to the one distance away opposite, at crawling +# speed, on an arc that lands at the same height we left from. +func _hop_across(distance: float) -> void: + var flightTime := distance / GROUND_SPEED + velocity.x = wallNormalX * GROUND_SPEED + velocity.y = -0.5 * get_gravity().y * flightTime + isHoppingAcross = true # Moves speed towards target: GROUND_ACCEL when speeding up, GROUND_FRICTION # when slowing down or stopping. -- 2.45.2 From f9f196d8c6770c97bbc90149ee9e41f6ec426091 Mon Sep 17 00:00:00 2001 From: SnekInAScarf Date: Sat, 31 Oct 2026 17:24:11 -0700 Subject: [PATCH 4/5] Fix falling off the wall right after a floor-edge wrap on right ledges When a wrap finishes, Godot still thinks we're on the floor we started from. On the finishing move_and_slide it then snapped us down onto it (floor_snap_length) and counted the wall we were pushed into as floor (floor_block_on_wall), so we landed as "on floor", stuck to nothing, and fell the next frame. It only happened on right-hand ledges because of how the contact lined up. Turn both off for the finishing move unless the wrap ends on a floor. Co-Authored-By: Claude Opus 5.5 --- Characters/player.gd | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Characters/player.gd b/Characters/player.gd index a39fabb..8b6c7ef 100755 --- a/Characters/player.gd +++ b/Characters/player.gd @@ -530,7 +530,18 @@ func _update_wrap(delta: float) -> void: # Done with move_and_slide so is_on_floor()/is_on_wall() are up to date # instead of still describing where we were before the wrap. velocity = -wrapOntoNormal * (WRAP_MARGIN + 1) / delta + # Godot still thinks we're on whatever floor we were on before the wrap, so + # it would try to snap us down onto it, and (floor_block_on_wall) count the + # wall we're pushing into as floor. Only allow that if we're ending on a floor. + var endingOnFloor := wrapOntoNormal == Vector2.UP + var floorSnap := floor_snap_length + var blockOnWall := floor_block_on_wall + if not endingOnFloor: + floor_snap_length = 0.0 + floor_block_on_wall = false move_and_slide() + floor_snap_length = floorSnap + floor_block_on_wall = blockOnWall # Carry on at the same speed along the new surface, so leaving the wrap # isn't a sudden stop. Normal movement then speeds up or slows down from here. var exitDirection := wrapExitOffset.normalized() if wrapExitOffset != Vector2.ZERO \ -- 2.45.2 From f167c74204c9941a83c5ba2954de93df2b8c766e Mon Sep 17 00:00:00 2001 From: SnekInAScarf Date: Sat, 31 Oct 2026 17:31:14 -0700 Subject: [PATCH 5/5] 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: -- 2.45.2