- Home /
Randomize Audio Clip
I have a simple script that plays a gameobjects audio source when that object is clicked. Instead of simply playing one audio clip over and over, I need to figure out how to randomize the audio clip that is played through the audio source. In other words, I need to figure out how to give the audio source an array of audio clips, then play them randomly. Does anybody have any suggestions as to how I might go about doing this? Any information/ references would be greatly appreciated! Thank you!
Answer by almo · Jul 19, 2011 at 06:13 PM
Create an array of AudioClips. Choose a random number from 0 to N - 1, where N is the number of clips in the array. Play that clip.
Your answer
Follow this Question
Related Questions
Need help to play a random explosion sound from an array. 1 Answer
pick a random int with the value of 1 from an array 2 Answers
Random footsteps 5 Answers
Random Audio Clip Help 3 Answers
Spawning Objects Using An Array. 1 Answer