From 1a7a43ab52a9b645addffd0d1278469fb1bc40cd Mon Sep 17 00:00:00 2001 From: SnekInAScarf Date: Mon, 16 Nov 2026 12:35:03 -0800 Subject: [PATCH] More options to unstick if on two surfaces. --- Characters/player.gd | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Characters/player.gd b/Characters/player.gd index d66c77c..3924e7e 100755 --- a/Characters/player.gd +++ b/Characters/player.gd @@ -83,6 +83,7 @@ const BRIDGE_FRAME = 10 # Wall to wall. Drawn upright, so it's turned a quarter. const BRIDGE_VERTICAL_FRAME = 11 # Floor to ceiling. const BRIDGE_GAP = 32.0 # One tile. const BRIDGE_GAP_TOLERANCE = 1.5 +const IN_AIR_FRAME = 8 # The InAir animation's frame. ############### ## Variables ## @@ -152,6 +153,7 @@ var isBridging := false var bridgeAxis := Vector2.RIGHT # RIGHT between walls, DOWN between floor and ceiling. var bridgeHoldSide := 0.0 # Which way along bridgeAxis we're holding (1, -1), or 0. var timeSpentLeavingBridge := 0.0 +var timeSpentDroppingFromBridge := 0.0 var carriedItem: CarryItem = null # The item riding in our center, or null. Tubes drop it. @@ -630,6 +632,7 @@ func _begin_bridge(normal: Vector2, ownPoint: Vector2, otherPoint: Vector2) -> v timeSpentHoldingUpOnFloor = 0.0 timeSpentHoldingEdge = 0.0 timeSpentLeavingBridge = 0.0 + timeSpentDroppingFromBridge = 0.0 # We're still holding away from the surface we left, towards the one across. # Keep holding and we cross over to it after HOLD_TIME, like any other hold. bridgeHoldSide = signf(normal.dot(bridgeAxis)) @@ -652,24 +655,54 @@ func _begin_bridge(normal: Vector2, ownPoint: Vector2, otherPoint: Vector2) -> v # Holding towards either surface for HOLD_TIME sticks us to it and lets go of # the other: left or right between walls, up or down between floor and ceiling. +# Holding down between walls, or left or right between floor and ceiling, for +# HOLD_TIME lets go of both and drops us. Diagonals do neither. func _update_bridge(delta: float, moveInput: Vector2) -> void: velocity = Vector2.ZERO var inputDirection := Vector2(moveInput.x, -moveInput.y) # Up is negative y. - var side := signf(inputDirection.dot(bridgeAxis)) + var along := signf(inputDirection.dot(bridgeAxis)) + var across := signf(inputDirection.dot(bridgeAxis.orthogonal())) + + var side := along if across == 0.0 else 0.0 if side != 0.0 and side == bridgeHoldSide: timeSpentLeavingBridge += delta else: timeSpentLeavingBridge = 0.0 bridgeHoldSide = side + # Between walls only down drops us (bridgeAxis.orthogonal() is up there). + var holdingToDrop := along == 0.0 and across != 0.0 + if bridgeAxis == Vector2.RIGHT: + holdingToDrop = holdingToDrop and inputDirection.y > 0.0 + if holdingToDrop: + timeSpentDroppingFromBridge += delta + else: + timeSpentDroppingFromBridge = 0.0 + if timeSpentLeavingBridge >= HOLD_TIME: _leave_bridge(bridgeAxis * side, delta) + elif timeSpentDroppingFromBridge >= HOLD_TIME: + _drop_from_bridge() + + +# Lets go of both surfaces and falls from where we are. +func _drop_from_bridge() -> void: + isBridging = false + timeSpentLeavingBridge = 0.0 + timeSpentDroppingFromBridge = 0.0 + velocity = Vector2.ZERO + # is_on_floor() and friends still describe where we bridged from. A move on + # the spot brings them up to date, so we don't count as on it. + move_and_slide() + _set_sprite_rotation(0.0) + _show_pose(&"InAir", IN_AIR_FRAME) # Sticks to the surface in `direction` from us. func _leave_bridge(direction: Vector2, delta: float) -> void: isBridging = false timeSpentLeavingBridge = 0.0 + timeSpentDroppingFromBridge = 0.0 var normal := -direction var gap := BRIDGE_GAP / 2.0 - _get_radius() _set_sprite_rotation(_rotation_for(normal))