Hop across to a surface within a tile (floor, walls and ceilings) #5

Merged
SnekInAScarf merged 5 commits from floor-hop into main 2026-10-31 20:47:40 -05:00
Showing only changes of commit f9f196d8c6 - Show all commits

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 # 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. # instead of still describing where we were before the wrap.
velocity = -wrapOntoNormal * (WRAP_MARGIN + 1) / delta 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() 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 # 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. # isn't a sudden stop. Normal movement then speeds up or slows down from here.
var exitDirection := wrapExitOffset.normalized() if wrapExitOffset != Vector2.ZERO \ var exitDirection := wrapExitOffset.normalized() if wrapExitOffset != Vector2.ZERO \