diff --git a/Audio/BulletFlyBySoundPlayer.tscn b/Audio/BulletFlyBySoundPlayer.tscn index eafc69c..ff8f98f 100644 --- a/Audio/BulletFlyBySoundPlayer.tscn +++ b/Audio/BulletFlyBySoundPlayer.tscn @@ -9,6 +9,7 @@ script = ExtResource( 2 ) [node name="SoundPlayer" parent="." instance=ExtResource( 1 )] SoundClip = "res://Assets/SFX/Weapons-BulletFlyBy-01.wav" AutoPlay = true +RandomizePitch = 0.3 [connection signal="finished" from="SoundPlayer/AudioStreamPlayer3D" to="." method="_on_AudioStreamPlayer3D_finished"] [editable path="SoundPlayer"] diff --git a/Audio/SoundPlayer.gd b/Audio/SoundPlayer.gd index 725f0aa..6d5a4b0 100644 --- a/Audio/SoundPlayer.gd +++ b/Audio/SoundPlayer.gd @@ -11,6 +11,8 @@ export(bool) var AutoPlay = false export(float) var MinimumRandomDistance = 0.35 # gives optimal playback repetition for sound clip groups of different sizes. export(bool) var PlayUntilEnd = false # determines if the play() function is allowed to sop a previously started sound export(float) var MinDelay = 0 # determines how many seconds must pass before the sound can be triggered again +export(float) var PitchScale = 1 +export(float) var RandomizePitch = 0 var min_distance = 0 # this determines how ofte na sound is allowed to play (any Nth time) this is calculated automatically based on maximum_repetition var clips = [] # holds loaded sound stream resources var recently_played = [] # holds indexes of recently played @@ -78,8 +80,13 @@ func play(): #print("recently played: ", recently_played) - player.stream = clips[i] + + if RandomizePitch != 0: + player.pitch_scale = PitchScale + rand_range(-RandomizePitch /2, RandomizePitch/2) + else: + player.pitch_scale = PitchScale + player.play() ready = false diff --git a/Player.tscn b/Player.tscn index 1c205ea..7350dbd 100644 --- a/Player.tscn +++ b/Player.tscn @@ -61,6 +61,7 @@ SoundClip = "res://Assets/SFX/Player-Jump-01.wav" SoundClip = "res://Assets/SFX/Player-Step-Concrete-01.wav" PlayUntilEnd = true MinDelay = 0.2 +RandomizePitch = 0.2 [node name="Death" parent="Sounds" instance=ExtResource( 7 )] SoundClip = "res://Assets/SFX/Player-Death-01.wav"