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 <noreply@anthropic.com>
This commit is contained in:
SnekInAScarf 2026-10-31 17:24:11 -07:00
parent e8cf70e6e5
commit f9f196d8c6

View file

@ -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 \