I’m using the following code to play a sound on loop when two objects are touching
void OnCollisionEnter2D(Collision2D col){
objectAudio.Play();
}
But the problem is it doesn’t stop playing when they stop colliding. How do I stop it?
I’m using the following code to play a sound on loop when two objects are touching
void OnCollisionEnter2D(Collision2D col){
objectAudio.Play();
}
But the problem is it doesn’t stop playing when they stop colliding. How do I stop it?
void OnCollisionExit2D (Collision2D collision) {
// stop playing the sound
}