How can I make a random sound

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RubRub

¿Cómo puedo hacer un sonido aleatorio? Por ejemplo,
si le agrego un temporizador a un nodo, que cada vez que termine reproduzca un sonido aleatorio, necesito ayuda, por favor

:bust_in_silhouette: Reply From: skysphr

If you mean play a sound at random from a list of sounds, check the pseudocode below:

var sounds = [load("res://sound1.ogg"), load("res://sound2.ogg"), ...]
$ = sounds[randi() % len(sounds)]

If you mean play a sound that is being generated on the fly, with random contents, the matter is very much not trivial.

oh thank you very much it served me I have been trying for months thank you very much

RubRub | 2021-10-26 00:27