- Home /
Duplicate Question
I have a shooting script. I have a problem: when firing bursts, my sound of a shot breaks. How to make the sound produced to the end.
AudioSource.Play(); -Not working correctly ;(
AudioSource.Play()
works perfectly fine... The thing is, if you destroy / disable the gameObject holding the audio source, then, the sound will stop....
As suggested by ConcanoPayno, use the method PlayOneShot
which has the particularity to not stop the sound, even if the gameObject is destroyed / disabled, or use the static method AudioSource.PlayClipAtPoint
which creates a temporary audio source with the desired volume, plays the sound, and destroys the AudioSource when the sound has finished.
FAQ :
Some reasons for getting a post rejected:
You haven't provided enough context: we need more information about your problem, relevant code snippets and what you have tried already.
There exists duplicate questions with answers if you were to do a search, either on Answers or on the Forum or on Unity's tutorials