- Home /
Audio Help
Why wont this work?
var on : KeyCode; var off :KeyCode; var audio01 : AudioClip; function Update () {
if (Input.GetKeyDown(on))
audio.Play(audio01);
if (Input.GetKeyDown(off))
audio.Stop(audio01);
}
there is always an error.
Comment
It would help to know what is the error.
But you are using audio.Play(AudioClip) - there is no such method.
If you have an audio source attached, you probably mean:
audio.clip = audio01;
audio.Play();
If you don't you probably mean:
AudioSource.PlayClipAtPoint( audio01, new Vector3(0,0,0) );
Your answer