summaryrefslogtreecommitdiff
path: root/character
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
parent474ef692613f298ab05bbb65ad85625f178b63cc (diff)
fix drop through wall bugHEADmain
Diffstat (limited to 'character')
-rw-r--r--character/character.gd31
-rw-r--r--character/character.tscn4
2 files changed, 21 insertions, 14 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:
diff --git a/character/character.tscn b/character/character.tscn
index 7fb9776..4c163cd 100644
--- a/character/character.tscn
+++ b/character/character.tscn
@@ -25,11 +25,11 @@ shape = SubResource("RectangleShape2D_wfm33")
[node name="RayLeft" type="RayCast2D" parent="."]
target_position = Vector2(-8, 0)
-collision_mask = 256
+collision_mask = 768
[node name="RayRight" type="RayCast2D" parent="."]
target_position = Vector2(8, 0)
-collision_mask = 256
+collision_mask = 768
[node name="RayUpLeft" type="RayCast2D" parent="."]
position = Vector2(-6, 0)