Only hop when not moving left/right; hop reach is one tile

- Holding left or right resets the hop timer, so the 0.5s hold only
  counts while standing still.
- HOP_MAX_HEIGHT is now 32 (one tile), as adjusted by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SnekInAScarf 2026-10-31 16:27:44 -07:00
parent 935ee797dc
commit 4b96d21add

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
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).
# 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_OVERSHOOT = 2.0 # Aim slightly past the ceiling so we still hit it with some speed.
var timeSpentHoldingUpOnFloor := 0.0
@ -166,9 +166,10 @@ func _physics_process(delta: float) -> void:
elif not is_on_floor():
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
# against a wall though, where up climbs it instead.
if is_on_floor() and not isStickingToWall and verticalInput > 0: timeSpentHoldingUpOnFloor += delta
# On the floor and standing still, holding up long enough hops up to the
# ceiling above. Not against a wall though, where up climbs it instead.
if is_on_floor() and not isStickingToWall and verticalInput > 0 and not horizontalInput:
timeSpentHoldingUpOnFloor += delta
else: timeSpentHoldingUpOnFloor = 0.0
if timeSpentHoldingUpOnFloor >= MAX_SECS_TO_UNSTICK:
timeSpentHoldingUpOnFloor = 0.0