mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-13 14:02:23 +02:00
Improved hero walking sounds
This commit is contained in:
@@ -20,6 +20,7 @@ onready var animation_state = animation_tree.get("parameters/playback")
|
|||||||
|
|
||||||
# Variables for sound selection
|
# Variables for sound selection
|
||||||
onready var walk_sounds = $Sounds/Walk
|
onready var walk_sounds = $Sounds/Walk
|
||||||
|
onready var walk_sound_timer = $Sounds/WalkSoundTimer
|
||||||
var _rng = RandomNumberGenerator.new()
|
var _rng = RandomNumberGenerator.new()
|
||||||
var is_playing_sound = false
|
var is_playing_sound = false
|
||||||
|
|
||||||
@@ -133,12 +134,20 @@ func _on_Hitbox_area_entered(area):
|
|||||||
func _walk_sound_finished():
|
func _walk_sound_finished():
|
||||||
is_playing_sound = false
|
is_playing_sound = false
|
||||||
|
|
||||||
|
func _walk_sound_wait_time():
|
||||||
|
var x = abs(velocity.length() / 100) - 1
|
||||||
|
return log(((x+1)/4)+2.5) / 3
|
||||||
|
# TODO: Rework anyone
|
||||||
|
|
||||||
func _play_random_sound(path = walk_sounds):
|
func _play_random_sound(path = walk_sounds):
|
||||||
if not is_playing_sound:
|
if walk_sound_timer.is_stopped() and not is_playing_sound:
|
||||||
var sound = path.get_children()[_rng.randi_range(0, path.get_child_count() - 1)]
|
var sound = path.get_children()[_rng.randi_range(0, path.get_child_count() - 1)]
|
||||||
sound.play()
|
sound.play()
|
||||||
is_playing_sound = true
|
is_playing_sound = true
|
||||||
|
|
||||||
|
walk_sound_timer.start(_walk_sound_wait_time())
|
||||||
|
print(_walk_sound_wait_time())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Overrides ready method for this entire script, checks for the finished method of each possible sound
|
# Overrides ready method for this entire script, checks for the finished method of each possible sound
|
||||||
|
|||||||
@@ -731,6 +731,9 @@ stream = ExtResource( 9 )
|
|||||||
|
|
||||||
[node name="AudioStreamPlayer5" type="AudioStreamPlayer" parent="Sounds/Walk"]
|
[node name="AudioStreamPlayer5" type="AudioStreamPlayer" parent="Sounds/Walk"]
|
||||||
stream = ExtResource( 8 )
|
stream = ExtResource( 8 )
|
||||||
|
|
||||||
|
[node name="WalkSoundTimer" type="Timer" parent="Sounds"]
|
||||||
|
one_shot = true
|
||||||
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
|
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
|
||||||
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
|
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
|
||||||
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]
|
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]
|
||||||
|
|||||||
Reference in New Issue
Block a user