Edge sensors: slide over the edges of floors, walls and ceilings #3

Merged
SnekInAScarf merged 2 commits from floor-edge-drop into main 2026-10-31 20:47:28 -05:00
Owner

Stacked on #2: this PR targets the smooth-edge-wrap branch. Merge #2 first, then change this PR's target to main (or merge it straight after).

What this does

Near the edge of any surface, pressing into that surface slides the slime to the edge, rolls it over the corner and onto the side of the platform.

On a… Press into it with Pick the side with Ends up on
Floor down left / right the wall below
Ceiling up left / right the wall above
Wall toward the wall up / down the floor on top, or the ceiling underneath
  • Rotating sensors: two RayCast2D nodes under an EdgeSensors pivot are rotated to point into whatever surface the slime is on, one a short way to each side. When one stops touching the surface, there's an edge in range on that side. You can see them in game with Debug → Visible Collision Shapes.
  • Which side: holding a direction along the surface picks that side. Otherwise the slime goes the way it's facing, or the other way if only that side has an edge in range. On walls, "facing" is the last direction you moved along the wall (up by default).
  • No edge in range (middle of a surface): nothing happens.
  • Inside corners: a sensor that starts inside something (for example, a floor running into a wall) is ignored, so it doesn't count as an edge.
  • Chains naturally: for example, drop off a floor edge, hold down + toward the wall to crawl down it, and you roll under onto the ceiling.

Sensor range

edgeSensorRange is exported, so you can tune it in the Inspector. The default is 24, picked from a headless sweep (slime radius 10):

Range Max gap between slime and edge Longest move
12 ~0px 14 frames
16 ~2px 16 frames
20 ~6px 18 frames
24 ~10px (half a slime) 19 frames (~0.3s)
32 ~18px 22 frames, slide feels long

Other changes to the wrap code

  • A wrap can start with a straight move to the beginning of the arc (used to slide to the edge first).
  • _begin_wrap takes the normal of the surface to end up on, works out the sprite rotation from it, and can now end on a ceiling.
  • Wraps finish with a move_and_slide(), so is_on_floor() / is_on_wall() / is_on_ceiling() describe where the slime ended up, not where it was before the wrap.

Testing

Tested headless in Godot 4.7.2 with scripts that build platforms, spawn the player and simulate input. All 18 cases pass:

  • Floor: left/right edges, facing vs. held direction, nothing in the middle, nothing when holding away from the only edge.
  • Ceiling: up + direction, up only with each facing, nothing in the middle.
  • Walls: near top → floor, near bottom → ceiling underneath (with and without up/down held), nothing in the middle.
  • Inside corner (floor running into a wall): no wrap.
  • Chained: floor → wall → ceiling underneath.
  • #2 regressions: lip hang then up, and climbing past a wall top.
  • test_level.tscn loads and runs with no errors.

Still worth a playtest for feel. Headless tests can't tell how it looks.

🤖 Generated with Claude Code

> **Stacked on #2:** this PR targets the `smooth-edge-wrap` branch. Merge #2 first, then change this PR's target to `main` (or merge it straight after). ## What this does Near the edge of any surface, pressing *into* that surface slides the slime to the edge, rolls it over the corner and onto the side of the platform. | On a… | Press into it with | Pick the side with | Ends up on | |---|---|---|---| | Floor | down | left / right | the wall below | | Ceiling | up | left / right | the wall above | | Wall | toward the wall | up / down | the floor on top, or the ceiling underneath | - **Rotating sensors:** two `RayCast2D` nodes under an `EdgeSensors` pivot are rotated to point into whatever surface the slime is on, one a short way to each side. When one stops touching the surface, there's an edge in range on that side. You can see them in game with **Debug → Visible Collision Shapes**. - **Which side:** holding a direction along the surface picks that side. Otherwise the slime goes the way it's facing, or the other way if only that side has an edge in range. On walls, "facing" is the last direction you moved along the wall (up by default). - **No edge in range** (middle of a surface): nothing happens. - **Inside corners:** a sensor that starts inside something (for example, a floor running into a wall) is ignored, so it doesn't count as an edge. - **Chains naturally:** for example, drop off a floor edge, hold down + toward the wall to crawl down it, and you roll under onto the ceiling. ## Sensor range `edgeSensorRange` is exported, so you can tune it in the Inspector. The default is **24**, picked from a headless sweep (slime radius 10): | Range | Max gap between slime and edge | Longest move | |---|---|---| | 12 | ~0px | 14 frames | | 16 | ~2px | 16 frames | | 20 | ~6px | 18 frames | | **24** | **~10px (half a slime)** | **19 frames (~0.3s)** | | 32 | ~18px | 22 frames, slide feels long | ## Other changes to the wrap code - A wrap can start with a straight move to the beginning of the arc (used to slide to the edge first). - `_begin_wrap` takes the normal of the surface to end up on, works out the sprite rotation from it, and can now end on a ceiling. - Wraps finish with a `move_and_slide()`, so `is_on_floor()` / `is_on_wall()` / `is_on_ceiling()` describe where the slime ended up, not where it was before the wrap. ## Testing Tested headless in Godot 4.7.2 with scripts that build platforms, spawn the player and simulate input. All 18 cases pass: - [x] Floor: left/right edges, facing vs. held direction, nothing in the middle, nothing when holding away from the only edge. - [x] Ceiling: up + direction, up only with each facing, nothing in the middle. - [x] Walls: near top → floor, near bottom → ceiling underneath (with and without up/down held), nothing in the middle. - [x] Inside corner (floor running into a wall): no wrap. - [x] Chained: floor → wall → ceiling underneath. - [x] #2 regressions: lip hang then up, and climbing past a wall top. - [x] `test_level.tscn` loads and runs with no errors. Still worth a playtest for feel. Headless tests can't tell how it looks. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
SnekInAScarf added 1 commit 2026-10-31 15:02:21 -05:00
Two RayCast2D edge sensors point down into the floor edgeSensorRange to
each side of the slime. When one stops touching floor there's an edge in
range on that side, and pressing down slides to it, swings over the
corner and carries on down the wall so the slime ends flat against it.

- Down + a direction picks that side; down alone goes the way the slime
  is facing, or the other way if only that side has an edge in range.
- Down in the middle of a platform does nothing.
- edgeSensorRange is exported (default 24, tuned with a headless sweep).
- Wraps can now start with a straight move to the arc, and end with a
  move_and_slide so is_on_floor()/is_on_wall() aren't stale afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SnekInAScarf added 1 commit 2026-10-31 15:11:16 -05:00
The edge sensors now live under an EdgeSensors pivot that's rotated to
point into whatever surface the slime is on. Pressing into the surface
(down on floors, up on ceilings, towards the wall on walls) near an edge
slides over it onto the side of the platform. The other axis picks the
side; otherwise facing decides (last direction moved along a wall).

- Ceiling edge -> wall above, wall top -> floor, wall bottom -> ceiling
  underneath, floor edge -> wall below, all through one code path.
- Skip sensors that start inside something (inside corners).
- _begin_wrap takes the normal of the surface to end up on and works
  out the sprite rotation from it; wraps can now end on a ceiling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SnekInAScarf changed title from Slide over floor edges onto the wall below when pressing down to Edge sensors: slide over the edges of floors, walls and ceilings 2026-10-31 15:11:32 -05:00
SnekInAScarf changed target branch from smooth-edge-wrap to main 2026-10-31 20:47:25 -05:00
SnekInAScarf merged commit f9c20f4de9 into main 2026-10-31 20:47:28 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: SnekInAScarf/SlimePlatformer#3
No description provided.