When a condition is met, I’d like to randomize the audio response. I know how to call a particular audio file... don’t know how to pick one at random.
Any advice how to do that? I expect to have 10-20 audio files to pick from.
Thank you in advance🙏
Develop games in your browser. Powerful, performant & highly capable.
You can name your audio files with hit_01, hit_02, ..., hit_20
Then you play audio by name:
Audio file name: "hit_" & random(1,20)
Maverick1912 Brilliant. Thank you!
You can also use choose("shoot1", "gun2", "firerocket_01")
in case your sound files don't match a common nomenclature.
Create a custom built-in function. "Play audio"
Create some parameters e.g. soundname, posx, posy, volume
On "play audio" : Audio: Play sample "soundname" at position "posx, "posy", volume: "volume"
Then you can use the function in any point of your event sheets and have a common method to play sounds.
-> On bullet collides with player: Call function "Play audio". soundname = choose("hit1","hit2"), posx = player.x, posy = player.y, volume = 0
I like that too. thanks!