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 4b96d21add - Show all commits

View file

@ -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 # How long to press opposite direction before unsticking from a wall/ceiling
const MAX_SECS_TO_UNSTICK = 0.5 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). # 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. # 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_NO_CEILING_HEIGHT = 16.0
const HOP_OVERSHOOT = 2.0 # Aim slightly past the ceiling so we still hit it with some speed. const HOP_OVERSHOOT = 2.0 # Aim slightly past the ceiling so we still hit it with some speed.
var timeSpentHoldingUpOnFloor := 0.0 var timeSpentHoldingUpOnFloor := 0.0
@ -166,9 +166,10 @@ func _physics_process(delta: float) -> void:
elif not is_on_floor(): elif not is_on_floor():
velocity.y = minf(velocity.y + get_gravity().y * delta, MAX_FALL_SPEED) 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 # On the floor and standing still, holding up long enough hops up to the
# against a wall though, where up climbs it instead. # ceiling above. Not against a wall though, where up climbs it instead.
if is_on_floor() and not isStickingToWall and verticalInput > 0: timeSpentHoldingUpOnFloor += delta if is_on_floor() and not isStickingToWall and verticalInput > 0 and not horizontalInput:
timeSpentHoldingUpOnFloor += delta
else: timeSpentHoldingUpOnFloor = 0.0 else: timeSpentHoldingUpOnFloor = 0.0
if timeSpentHoldingUpOnFloor >= MAX_SECS_TO_UNSTICK: if timeSpentHoldingUpOnFloor >= MAX_SECS_TO_UNSTICK:
timeSpentHoldingUpOnFloor = 0.0 timeSpentHoldingUpOnFloor = 0.0