If this is how standard Audio Sources can be used, how might I use a Snapshot in a similar context? I get the feeling this isn’t what Audio Mixer was intended for, but I’m curious to see if it’s possible.
public class PlayerAudio : MonoBehaviour {
public AudioMixerSnapshot lightAttack;
public AudioMixerSnapshot heavyAttack;
public AudioMixer playerCombat;
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse1))
GetComponent<AudioSource>().Play();
if (Input.GetKeyUp(KeyCode.Mouse1))
GetComponent<AudioSource>().Stop();
}
Thanks, that helped a little bit. But I’m still not sure I understand how to use them. I selected correct the snapshot within the script in Unity’s inspector, but it still doesn’t play the audio on button press.
I got the audio to work on button press when I was working with the standard Audio Source, and I had no issue activating Snapshots with triggers. But this function is giving me grief. What am I doing wrong?
public AudioMixerSnapshot lightattack;
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse1))
lightattack.TransitionTo(.01f);
}