drowning muffles and reverbs the audio

This commit is contained in:
pennyrigate 2023-06-25 16:13:46 -04:00
parent 8330b50ab3
commit a096a4c6c5
7 changed files with 246 additions and 72 deletions

View file

@ -105,9 +105,12 @@ func _physics_process(delta: float) -> void:
if underwater:
if oxygen_timer.time_left < 5:
low_oxygen_label.text = str(floor(oxygen_timer.time_left) + 1)
set_underwater_audio(true)
else:
low_oxygen_label.text = ""
set_underwater_audio(false)
else:
#NOT UNDERWATER
low_oxygen_label.text = ""
#Cheats
@ -130,6 +133,10 @@ func spawn_arrow() -> void:
func die() -> void:
state_chart.send_event("hurt")
func set_underwater_audio(value):
var idx = AudioServer.get_bus_index("Master")
AudioServer.set_bus_effect_enabled(idx,0,value)
AudioServer.set_bus_effect_enabled(idx,1,value)
# STATE ENTERS/EXITS #
func _on_Grounded_state_entered() -> void:
@ -402,4 +409,8 @@ func _on_Ducking_event_received(event):
func _on_OxygenTimer_timeout():
if underwater: die()
#Reset low oxygen effect when leaving level
func _on_Player_tree_exited():
set_underwater_audio(false)

View file

@ -1401,12 +1401,13 @@ margin_bottom = -18.0
theme = ExtResource( 7 )
align = 1
[connection signal="tree_exited" from="." to="." method="_on_Player_tree_exited"]
[connection signal="body_entered" from="Hitbox" to="." method="_on_Hitbox_body_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement" to="." method="_process_movement"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded" to="." method="_on_Grounded_state_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded" to="." method="_process_grounded"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_can_walk"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_horizontal_movement_grounded"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_can_walk"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Still" to="." method="_on_Still_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Walking" to="." method="_on_Walking_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Blinking" to="." method="_on_Blinking_state_entered"]