- Home /
Multiple sound sources of the same sound file
Hello Unity Answers
In what I am certain is a less than optimal way to go about playing multiple instances of the same sound, I have created a metric ton of different empty Game Objects that functions as Sound Sources.
The problem I am working on is this: I want to be able to play a tone repeatedly and possibly overlapping. My program is a basic "create some notes and play music" kind of setup, where the user has to be able to start a tone when desired. There seems to be a fairly large problem in the way I (or Unity?) grasps this task. When the user activates a Sound Source NOTE, let us call it SS-A-NOTE-1, and activates the same note through a different Sound Source, SS-B-NOTE-1, it cuts SS-A-NOTE-1 off in order to play the newly requested note, even though the same Sound Source Object is not invoked. I am using a simple SoundSource.Play() function to get it to start each note.
As far as I have been able to tell, this is caused by the actual audio-file being the same, since the problem does not occur in any configuration of non-identical notes. Is there an option that allows me to play the same notes without cutting the previous one short, and without adding what would be a ridiculous amount of audio-files to the build?
Answer by Juice-Tin · Jan 08, 2015 at 11:39 PM
http://docs.unity3d.com/ScriptReference/AudioSource.PlayOneShot.html Play a any sound from a single sound source as often or overlapping as needed.
That does seem to have been a major improvement, thank you =D
Hmmm, it seems like the cut-off is still present now that I have listened a little closer. I was apparently listening to the tones with a markedly shorter tail-fade, while the longer lasting tones still seem to get interrupted by the repeat audio.PlayOneShot(---) calls.