- Home /
How can I play a sound every time a particle is emitted?
I know that this was formerly possible with
function Update () {
if (gameObject.particleEmitter.emit) {
audio.Play();
}
}
But this doesn't seem possible anymore with the new particle system. Some have suggested syncing up the sound with the emissionRate but this seems like a sloppy mess if the emissionRate is going to be changed later. Any help would be much appreciated.
Answer by Laumania · Aug 21, 2019 at 12:00 PM
I might be 5 years too late here, but in case others find this thread too - here is how I solved playing a sound when a particle is emitted and once it dies: https://www.youtube.com/watch?v=jKSz8JJnL4E
Hope somebody find it useful.
Enjoy!
I have done a new an updated video with a little more advanced script than in the previous one - hope it helps someone: https://www.youtube.com/watch?v=q_j$$anonymous$$iFHy93Y
Answer by Dryrainstudios · Sep 03, 2015 at 01:23 AM
I know it was a while ago but did you see this? http://answers.unity3d.com/questions/693044/play-sound-on-particle-emit-sub-emitter.html
Answer by jblazer · Apr 22, 2014 at 04:55 PM
So I was looking for an answer to this with a looping particle system (Shuriken) and trying to sync audio to a timed interval loop. I was able to get something working - maybe a workaround to not having emit available… this basically plays a one-shot audio at the start of the particle loop… You may have to play with the .1 value - I recently noticed it was playing the sound more than once. Maybe put it in a fixed update loop instead and reduce this to a timed interval… but was able to get a working solution for our game with this method...
var air : AudioClip;
function Update(){
if (particleSystem.time <= .1f){
audio.PlayOneShot(air);
}
}