Newbie here!
I have an animator prefab that gets instantiated to which an audio source is added which eventually have an audio clip. I have a script which would play the clip when the prefab is clicked as follows.
public class destroy : MonoBehaviour {
void Start () {
AudioSource audio = GetComponent<AudioSource>();
}
void Update () {
}
void OnMouseDown(){
audio.Play ();
Destroy(this.gameObject);
}
}
for some reason my clip is not being played. The OnMouseDown() is working though. Please help me. Thanks in alvance