Fix sideways pipe hitbox collision (#730)

* Fixed sideways pipe hitbox collision

This fixes a bug where players would clip the top edge of a sideways pipe's hitbox and get counted as being on the floor despite being above the pipe, thus allowing them to get warped into the pipe from there.

* Fix to prevent entering pipes from too low

this implements a simple distance check from the player to the hitbox to ensure the player can only ever enter the pipe when they're close enough in proximity to the pipe, preventing them from entering from a tile too low.

* co mnment

:earnest:
This commit is contained in:
SkyanUltra 2025-11-22 11:32:59 -05:00 committed by GitHub
parent 06dafbace2
commit a681fed56d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,10 +43,13 @@ func run_pipe_check() -> void:
exit_pipe()
func _physics_process(_delta: float) -> void:
# SkyanUltra: Adjusted logic to offset pipe hitbox rather than stretching it,
# as it allowed characters to clip the edge of the pipe and get counted as
# grounded, getting warped into pipes from above.
if enter_direction >= 2:
$Hitbox.scale.y = 8
$Hitbox.position.y = 14
else:
$Hitbox.scale.y = 1
$Hitbox.position.y = 0
if Engine.is_editor_hint() == false:
in_game()
@ -111,8 +114,9 @@ func in_game() -> void:
func run_player_check(player: Player) -> void:
# guzlad: Added support for characters with a hitbox height below 1.0 to enter pipes underwater
print(player.is_actually_on_floor())
if Global.player_action_pressed(get_input_direction(enter_direction), player.player_id) and (player.is_on_floor() or enter_direction == 1):
# SkyanUltra: Added distance check to prevent entering pipes from too low.
var distance = player.global_position.distance_to(hitbox.global_position)
if distance <= 6 and Global.player_action_pressed(get_input_direction(enter_direction), player.player_id) and (player.is_actually_on_floor() or enter_direction == 1):
can_enter = false
pipe_entered.emit()
DiscoLevel.can_meter_tick = false