Hey!
I am having an animator gameobject to which I have attached a sound source.
I need the audio to be played when I click my gameobject.
Here is my code.
public class destroy : MonoBehaviour {
private AudioSource source;
void Update () {
}
void OnMouseDown(){
source = GetComponent<AudioSource>();
source.Play ();
//source.PlayOneShot ((AudioClip)Resources.Load("BOING_"));
}
}
The sound is being played. But the problem is it is getting played well before I click them. To be more precise its being played when the game starts.
Please help me in solving this.
Thanks in advance!!