I been researching how to do this and it seems that it doesn’t work in Unity 5. I have two audio attached to a gameobject. ‘swoosh’ and ‘death’. I want to play death during collision and my code seems to not working.
AudioSource source
void Start () {
source = GetComponent<AudioSource> ();
}
void OnTriggerEnter2D(Collider2D collider){
if (collider.tag == "Player") {
source.PlayOneShot(swoosh);
}
}
I keep getting error `swoosh’ does not exist in the current context. I’ve seen people doing this in tutorials but it seems to be not working on mine. I’m using Unity 5