- Home /
How to stop playing sound when objects stop touching?
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?
Comment
Best Answer
Answer by Eyes-Wide-Shut · Apr 25, 2019 at 02:13 AM
void OnCollisionExit2D (Collision2D collision) {
// stop playing the sound
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612200147im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
One Slider Control More Than One Sound 1 Answer
How can we change default playback device in unity? 2 Answers
Can't stop audio source after going away from trigger 0 Answers
Audio fade in and out? 1 Answer
Slider for Game-Wide Audio 0 Answers