23 lines
544 B
GDScript
23 lines
544 B
GDScript
extends AudioStreamPlayer
|
|
|
|
class_name RandomAudioStreamPlayer
|
|
|
|
@export var audio_collections: Array[AudioStreamCollection] = []
|
|
|
|
|
|
func _init() -> void:
|
|
bus = "game_sfx"
|
|
|
|
|
|
func play_random():
|
|
if audio_collections == null:
|
|
push_warning("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
|
|
# pitch_scale = randf_range(.8, 1)
|
|
play()
|