From 6622544acb1aa32899fbd7c77692af8086de187d Mon Sep 17 00:00:00 2001 From: SnekInAScarf Date: Sat, 31 Oct 2026 17:44:49 -0700 Subject: [PATCH] Remove the lip hang, which the edge hold has made unreachable The edge hold stops the slime before it leaves a ceiling, so the lip (hanging just past a ceiling edge after leaving it) never started any more: 0 times in 116 ceiling-edge crawls covering both directions, many starting points and thin/thick platforms. Removes its state, _start_lip_wrap, CLIMB_INPUT_BUFFER and timeSinceUpPressed. _start_wall_top_wrap keeps its own raycasts: it runs after we've passed the corner, where _find_edge_corner can't see it. Comment added. Co-Authored-By: Claude Opus 5.5 --- Characters/player.gd | 75 ++++++-------------------------------------- 1 file changed, 9 insertions(+), 66 deletions(-) diff --git a/Characters/player.gd b/Characters/player.gd index 1d3e643..4c1e8a9 100755 --- a/Characters/player.gd +++ b/Characters/player.gd @@ -22,7 +22,7 @@ const WALL_STICK_SPEED = 20.0 # Small push into the wall that keeps the slime pr const SURFACE_SNAP_DISTANCE = 4.0 # How long to hold a direction before something happens: letting go of a wall # or ceiling (holding away from it), carrying on over an edge we're holding at, -# hopping, and how long we hang on a lip. +# and hopping. const HOLD_TIME = 0.5 var isStickingToWall := false @@ -68,15 +68,6 @@ var wrapOntoNormal := Vector2.UP # Normal of the surface we end up on. var wrapSpeed := 0.0 # Eases up to GROUND_SPEED, so starting from a standstill isn't a jolt. var wrapTravelled := 0.0 -# ---- Lip ---- -# Fallback for going over a ceiling edge without the edge hold catching it: -# we hang just past the edge for HOLD_TIME, and pressing up wraps onto the wall above. -const CLIMB_INPUT_BUFFER = 0.15 # Tapping up this long before reaching a lip still counts. -var isHangingOnLip := false -var timeSpentOnLip := 0.0 -var lipDirection := 0.0 # Which way we were moving when we went over the lip. -var timeSinceUpPressed := 1.0 - # ---- Hops ---- # Holding up (and not left/right) on the floor for HOLD_TIME hops just high # enough to reach a ceiling up to HOP_REACH above us (measured from our top). @@ -125,22 +116,14 @@ func _physics_process(delta: float) -> void: var horizontalInput := Input.get_axis("moveLeft", "moveRight") var verticalInput := Input.get_axis("moveDown", "moveUp") - if Input.is_action_just_pressed("moveUp"): timeSinceUpPressed = 0.0 - else: timeSinceUpPressed += delta - # Swinging around a corner, ignore everything else until we're done. if isWrapping: _update_wrap(delta) return - var wasInAir := _get_surface_normal() == Vector2.ZERO and not isHangingOnLip + var wasInAir := _get_surface_normal() == Vector2.ZERO 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 - if isHangingOnLip and wantsToClimb and _start_lip_wrap(): - return - # Near the edge of a surface and pressing into it: wrap over onto the # side of the platform. if isStickingToWall and verticalInput: wallFacingY = -signf(verticalInput) @@ -163,7 +146,7 @@ func _physics_process(delta: float) -> void: if wasOnWall and not isStickingToWall and verticalInput > 0 \ and timeSpentUnstickingWall < HOLD_TIME and _start_wall_top_wrap(): return - _update_ceiling_sticking(delta) + _update_ceiling_sticking() # In a corner touching both wall and ceiling, only stick to one # surface depending on if we're pressing into the ceiling or not. @@ -203,10 +186,6 @@ func _update_vertical_movement(delta: float, horizontalInput: float, verticalInp # Move up and down along a wall when sticking to it. elif isStickingToWall: velocity.y = _accelerate(velocity.y, -CLIMB_SPEED * verticalInput, delta) - # Don't fall while hanging on a lip. Pressing up there normally starts a lip - # wrap first; this only climbs if the wrap couldn't find the corner. - elif isHangingOnLip: - velocity.y = -CLIMB_SPEED if verticalInput > 0 else 0.0 elif not is_on_floor(): velocity.y = minf(velocity.y + get_gravity().y * delta, MAX_FALL_SPEED) @@ -239,12 +218,7 @@ func _update_horizontal_movement(delta: float, horizontalInput: float, verticalI return timeSpentUnstickingWall = 0.0 - # Hanging on a lip. Pressing up there normally starts a lip wrap first; if - # that couldn't find the corner, push back towards the platform so physics - # slides us around it onto the wall instead. - if isHangingOnLip: - velocity.x = -lipDirection * WALL_STICK_SPEED if verticalInput > 0 else 0.0 - elif is_on_floor() or isStickingToCeiling: + if is_on_floor() or isStickingToCeiling: velocity.x = _accelerate(velocity.x, horizontalInput * GROUND_SPEED, delta) elif not isHoppingAcross: velocity.x = _air_steer(velocity.x, horizontalInput, delta) @@ -256,27 +230,11 @@ func _update_wall_sticking(wasOnWall: bool) -> void: and _snap_to_surface(Vector2(wallNormalX, 0))) if isStickingToWall: wallNormalX = get_wall_normal().x -# After moving: are we still on the ceiling, and did we just go over its edge -# onto a lip? -func _update_ceiling_sticking(delta: float) -> void: - if isHangingOnLip: - timeSpentOnLip += delta - if timeSpentOnLip >= HOLD_TIME: isHangingOnLip = false - else: timeSpentOnLip = 0.0 - +# After moving: are we still on the ceiling? If we drifted slightly off it, +# pull back onto it instead of falling off. +func _update_ceiling_sticking() -> void: var wasOnCeiling := isStickingToCeiling isStickingToCeiling = is_on_ceiling() or (wasOnCeiling and _snap_to_surface(Vector2.DOWN)) - # Only walking off the ceiling's edge counts as a lip, not landing on - # a ceiling, letting go of it by pressing down, or after already holding - # at the edge long enough to let go. - if wasOnCeiling and not isStickingToCeiling and not isStickingToWall and velocity.x != 0.0 \ - and timeSpentHoldingEdge < HOLD_TIME: - isHangingOnLip = true - lipDirection = signf(velocity.x) - # Made it onto the wall from the lip. - if isHangingOnLip and isStickingToWall: - isHangingOnLip = false - ignoreWallUnstickUntilRelease = true # Rotates the sprite to sit on the wall or ceiling. Done in _physics_process # (not _process) so physics interpolation smooths it along with our movement. @@ -428,23 +386,9 @@ func _hold_at_edge(delta: float) -> void: timeSpentHoldingEdge += delta velocity += direction * (maxf(distanceToEdge, 0.0) / delta - absf(speed)) -# Just went over a ceiling edge: find the corner and swing up beside the wall. -func _start_lip_wrap() -> bool: - var direction := lipDirection - var radius := _get_radius() - var pos := global_position - # Bottom of the platform we just came off of. - var ceilingHit := _cast_ray(pos - Vector2(direction * (radius + 2), 0), pos - Vector2(direction * (radius + 2), radius * 2)) - if not ceilingHit or ceilingHit.normal.y < 0.5: return false - var ceilingY: float = ceilingHit.position.y - # Side of the platform, just above its bottom. - var faceHit := _cast_ray(Vector2(pos.x + direction * radius, ceilingY - 2), Vector2(pos.x - direction * radius * 2, ceilingY - 2)) - if not faceHit or faceHit.normal.x * direction < 0.5: return false - var corner := Vector2(faceHit.position.x, ceilingY) - # After the arc, carry on up the wall so our side is flat against it. - return _begin_wrap(corner, Vector2(direction, 0).angle(), Vector2(0, -radius), Vector2(direction, 0)) - # Just climbed past the top of a wall: find the corner and swing up on top. +# (By now we've already passed the corner, so _find_edge_corner, which looks +# from the surface we're still on, can't see it. Hence the separate raycasts.) func _start_wall_top_wrap() -> bool: var wallNormal := wallNormalX var radius := _get_radius() @@ -543,7 +487,6 @@ func _finish_wrap(delta: float) -> void: velocity = exitDirection * wrapSpeed isWrapping = false - isHangingOnLip = false isStickingToCeiling = wrapOntoNormal.y > 0.5 isStickingToWall = absf(wrapOntoNormal.x) > 0.5 if isStickingToWall: