summaryrefslogtreecommitdiff
path: root/character/character.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-30 11:41:09 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-30 11:41:14 +0100
commit24a8f1b156ea92e7b0ad60052521e1430a77e13f (patch)
treee2e21d5015e8003e6ba40dc85a19bc9d523e249f /character/character.gd
parent474ef692613f298ab05bbb65ad85625f178b63cc (diff)
fix drop through wall bugHEADmain
Diffstat (limited to 'character/character.gd')
-rw-r--r--character/character.gd31
1 files changed, 19 insertions, 12 deletions
diff --git a/character/character.gd b/character/character.gd
index ef18bbc..764c02e 100644
--- a/character/character.gd
+++ b/character/character.gd
@@ -150,21 +150,28 @@ func is_on_floor() -> bool:
return $RayDownLeft.is_colliding() or $RayDownRight.is_colliding()
-func is_on_ledge() -> bool:
- return true
- pass
- # TODO: add two more down Rays
- # and up rays for is_below wall and is_below_ledge
- # to fix falling through wall
- # funktion im base-game aber auch gar nicht vorhanden:)
+func _is_on_ledge() -> bool:
+ var is_on := false
+
+ if $RayDownLeft.is_colliding():
+ is_on = is_on or $RayDownLeft.get_collider().is_ledge($RayDownLeft.get_collision_point())
+
+ if $RayDownRight.is_colliding():
+ is_on = is_on or $RayDownRight.get_collider().is_ledge($RayDownRight.get_collision_point())
+
+ return is_on
-func is_on_bottom_floor() -> bool:
- var stage: Stage = get_tree().current_scene
- var map: TileMapLayer = get_tree().get_first_node_in_group("tilemap")
- var bottom = position.y + (get_sprite_size().y / 2) + map.tile_set.tile_size.y
+func is_on_solid_floor() -> bool:
+ var is_on := false
+
+ if $RayDownLeft.is_colliding():
+ is_on = is_on or $RayDownLeft.get_collider().is_wall($RayDownLeft.get_collision_point())
+
+ if $RayDownRight.is_colliding():
+ is_on = is_on or $RayDownRight.get_collider().is_wall($RayDownRight.get_collision_point())
- return bottom >= stage.get_world_boundaries()[Vector2.DOWN]
+ return is_on
func is_below_ceiling() -> bool: