Hey guys!
So I have an empty object which I have an Audio Source including an attached looped background track. I also have a script on the empty object which takes in two Audio Clips. When the user presses one button, one of the clips play, when they press the other the other clip plays. It works great but I am looking to have some more flexibility.
I would like to adjust volume and pitch of the individual Audio Clips without adjusting the background track. I am not sure how to do this though, since all of the sounds are sharing the same Audio Source. I would like to have them all sharing the Audio Source and be adjustable but have not found a clear solution to achieve this.
Any insight or assistance would be greatly appreciated!
Thanks guys!
Here is how I am playing each button sound, this is attached to my empty object that also has the Audio Source on it with the background track:
public var click : AudioClip;
public var click2 : AudioClip;
function OnClick(button : String)
{
if(button == "Button 1")
{
PlayClick(1);
}
if(button == "Button 2")
{
PlayClick(2);
}
}
function PlayClick(val : int)
{
if(val == 1)
{
GetComponent(AudioSource).PlayOneShot(click);
}
if(val == 2)
{
GetComponent(AudioSource).PlayOneShot(click2);
}
}