Recently I started making a prototype game in Unity. But I have some problems with the audio. I use audio.Play(); but nothing happens. Here is the code:
The initialization:
public AudioClip jumpland;
AudioSource audio;
void Start() { audio = gameObject.GetComponent<AudioSource> (); }
Playing the Sound:
void OnTriggerEnter2D(Collider2D col) {
if (down.GetComponent<BoxCollider2D> ().gameObject.tag == "block") {
audio.clip = jumpland;
audio.Play ();
}
}
The audio clip is assigned but it wont play.