2024-12-23 01:30:31 +00:00
|
|
|
extends AudioStreamPlayer
|
|
|
|
|
|
|
|
class_name RandomAudioStreamPlayer
|
|
|
|
|
|
|
|
@export var audio_collections := [] as Array[AudioStreamCollection]
|
|
|
|
|
2024-12-25 12:24:34 +00:00
|
|
|
func _init() -> void:
|
|
|
|
bus = "game_sfx"
|
|
|
|
|
2024-12-23 01:30:31 +00:00
|
|
|
func play_random():
|
|
|
|
if audio_collections == null:
|
|
|
|
push_error("empty audio_collections")
|
|
|
|
return
|
|
|
|
var audio_collection:=audio_collections.pick_random() as AudioStreamCollection
|
|
|
|
stream = audio_collection.audios.pick_random()
|
|
|
|
if stream == null:
|
|
|
|
push_error("empty stream in audio_collection", audio_collection)
|
|
|
|
return
|
2024-12-30 13:19:10 +00:00
|
|
|
# pitch_scale = randf_range(.8, 1)
|
2024-12-23 01:30:31 +00:00
|
|
|
play()
|