I am trying to add sound with javascript in my unity game. but it does not work. i have audio source attached to gameobject as well. i want to sound to play when gameobject collides with another gameobject then it should play sound. i do not know hat is wrong with my code/ i would be greatful if someone helps in adding sound.
Below is my code that i am trying to add sound to
Thanks.
var Cherrypoint : int = 10;
var pickupSound : AudioClip;
function OnCollisionEnter2D(coll: Collision2D) {
if (coll.gameObject.tag == "Player")
Score_Fruitcatch.Fruitscore += Cherrypoint ;
//Debug.Log("destroyed");
audio.Play();
Destroy(gameObject);
}