- Home /
How to determine which audiosource to play from when I'm using two at once.
I've got a vehicle (A toboggan!) with two audiosources attached, and one script controlling the audio.
One audioscource loops. It's called "Sliding". It rises and lowers in pitch and volume based on velocity. The other audioscource is called "crunching". It plays my miscellaneous sounds, such as impacts.
The problem is that when I play a sound:
audio.PlayOneShot(thump1);
It chooses the Sliding audiosource (And so it affects my pitch and volume), but I want it to play using the Crunching audiosource.
In C#, how can I tell it explicitly which audiosource to choose?
Answer by DaveA · Aug 16, 2013 at 01:04 AM
If you need to play 2 sounds at the same time, make a new empty object and make it a child of the toboggan, and put a different audio source on it. Generally it's a good idea to have only 1 component of any type on a game object.
Yeah, that's what I thought I'd have to do. I was hoping there would be some kind of script support for accessing each one more elegantly.
Thanks for the info.