- Home /
Random, 3d sound.
Hi, I'm making a maze.
I want to have an audio source on my endPoint that plays and loops a random track. I want the sound to get faint as you walk away from it, but very intense as you get closer.
Can anyone point me in the right direction?
Thanks,
kyle
Answer by Jesse Anders · Dec 01, 2010 at 04:35 PM
The attenuation should simply be a matter of importing the relevant sound clip(s) with '3D Sound' on (the default, I believe), placing the audio source where you want it, and adjusting the falloff settings (min and max distance, falloff curve, etc.) appropriately.
For playing a track randomly, you can create a 'play random track' script and attach it to the audio source game object, create a public array of audio clips and assign clips to it in the inspector, and then in the Awake() or Start() function, choose a clip at random using Random.Range(), assign the clip to the audio source, and then call AudioSource.Play().
Your answer
Follow this Question
Related Questions
Playing a sound clip from another object 1 Answer
Get audio from device... -1 Answers
Help with sound clips [C#] 0 Answers
Set audio clip to 3D in script 1 Answer
Audio not coming out of speakers 1 Answer