- Home /
Streaming an ogg file via WWW results in non 3d sound
Is there any way of forcing a sound to become 3d? I am laoding the file via WWW. However the resulting effect is the sound playing at a constant level whichever distance the listener is. Btw I have tryed to default the audio source as a)none and b) with a 3d sound; and then when the sound is triggered I add the following:
var download = new WWW (path);
yield download;
var clip : AudioClip = download.oggVorbis;
if (clip != null)
{
audio.clip = clip;
audio.rolloffMode = AudioRolloffMode.Logarithmic;
audio.spread=0.25; audio.minDistance=1;
audio.minDistance=10;
audio.ignoreListenerVolume=true;
audio.panLevel = 1f;
audio.Play();
}
Any clue?
@xtnz: You tagged your question well. Try to format your code next time, so we can actually read it. Press the 010101
button while selecting your complete code. Use a new line for every line of code.
But this was key:
var clip : AudioClip = download.GetAudioClip(true); //Ins$$anonymous$$d of download.oggVorbis;
Answer by Bunny83 · Jun 24, 2011 at 02:32 PM
http://unity3d.com/support/documentation/ScriptReference/AudioSource.html
"Mono sounds play back 3D. [...] Stereo sounds are always played back without distance based attenuation."
http://unity3d.com/support/documentation/Components/class-AudioClip.html
"Both mono and multiple channel sounds can be positioned in 3D. For multiple channel audio, use the spread option on the Audio Source to spread and split out the discrete channels in speaker space."