Is there a way for Unity to stop cutting the sound that is currently playing, to try to play a newer sound (this only happens when the sounds being played go over a certain limit).
For example, imagine missiles hitting a target in succession, at a interval of 1 second between impact. On each impact an explosion of 1.4 seconds is played, but Unity never finishes playing the complete sound, it always cuts it to play a new one, and a new one, etc.
Anyone know a solution for this ?
ok, so your explosion sound effect is tied to the missile?
What I would do it have the explosion instantiate a prefab at the impact point using an empty game object with some code that uses play audio at position:
I find this extremely useful and use it for a lot of things.
Yup, my explosion sound is tied to the missile.
So, you suggest to instantiate an empty prefab with the code to call this AudioSource.PlayClipAtPoint , and using the game general AudioSource ?
I will give it a try.
Well yeah, because Im assuming whats happening is that your missile is being destroyed with the audio that’s tied to it, thus removing the sound from your game world instantly.
If you instead instantiate a sound to occur when the missile impacts, independent of the missile prefab, then the missile can be destroyed without removing the audio. Once the audio finishes playing, you can destroy that. Or actually, I think you should be able to just add the PlayCLipAtPoint inside your missile script on impact, it should play till its finished even if the missile is destroyed. Just do some R&D this way, you’ll get it.