disable collision while drowning (fixes #133)

This commit is contained in:
Haze Weathers 2023-06-30 19:03:16 -04:00
parent 85478370b4
commit 2974cce19e
2 changed files with 11 additions and 1 deletions

View file

@ -54,6 +54,7 @@ onready var pushable_detector: RayCast2D = $"%PushableDetector"
onready var oxygen_timer = $OxygenTimer onready var oxygen_timer = $OxygenTimer
onready var low_oxygen_label = $LowOxygenLabel onready var low_oxygen_label = $LowOxygenLabel
onready var edge_detector = $Graphics/EdgeDetector onready var edge_detector = $Graphics/EdgeDetector
onready var body_shape: CollisionShape2D = $"%BodyShape"
# OVERRIDES # # OVERRIDES #
func _ready() -> void: func _ready() -> void:
@ -274,6 +275,13 @@ func _on_Respawn_state_entered() -> void:
func _on_Edge_state_entered(): func _on_Edge_state_entered():
animation_player.play("edge") animation_player.play("edge")
func _on_Inactive_state_entered() -> void:
body_shape.disabled = true
func _on_Inactive_state_exited() -> void:
body_shape.disabled = false
# STATE PROCESSING # # STATE PROCESSING #
## when on ground ## when on ground
func _process_grounded(delta: float) -> void: func _process_grounded(delta: float) -> void:

View file

@ -1013,7 +1013,7 @@ tracks/3/keys = {
[node name="Player" type="KinematicBody2D" groups=["player"]] [node name="Player" type="KinematicBody2D" groups=["player"]]
collision_layer = 128 collision_layer = 128
collision_mask = 7 collision_mask = 7
moving_platform_apply_velocity_on_leave = 1 moving_platform_apply_velocity_on_leave = 2
script = ExtResource( 1 ) script = ExtResource( 1 )
walk_acceleration_frames = 4.0 walk_acceleration_frames = 4.0
gravity = 700.0 gravity = 700.0
@ -1562,6 +1562,8 @@ align = 1
[connection signal="state_entered" from="StateChart/Root/Movement/Climbing" to="." method="_on_Climbing_state_entered"] [connection signal="state_entered" from="StateChart/Root/Movement/Climbing" to="." method="_on_Climbing_state_entered"]
[connection signal="state_exited" from="StateChart/Root/Movement/Climbing" to="." method="_on_Climbing_state_exited"] [connection signal="state_exited" from="StateChart/Root/Movement/Climbing" to="." method="_on_Climbing_state_exited"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Climbing" to="." method="_process_climbing"] [connection signal="state_physics_processing" from="StateChart/Root/Movement/Climbing" to="." method="_process_climbing"]
[connection signal="state_entered" from="StateChart/Root/Movement/Inactive" to="." method="_on_Inactive_state_entered"]
[connection signal="state_exited" from="StateChart/Root/Movement/Inactive" to="." method="_on_Inactive_state_exited"]
[connection signal="state_entered" from="StateChart/Root/Health/Respawn" to="." method="_on_Respawn_state_entered"] [connection signal="state_entered" from="StateChart/Root/Health/Respawn" to="." method="_on_Respawn_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Health/Dead" to="." method="_on_Dead_state_entered"] [connection signal="state_entered" from="StateChart/Root/Health/Dead" to="." method="_on_Dead_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Health/Drowning" to="." method="_on_Drowning_state_entered"] [connection signal="state_entered" from="StateChart/Root/Health/Drowning" to="." method="_on_Drowning_state_entered"]