Detect the start of a particle burst emission

Hi,

I have a particle system that only emits in bursts which are random in execution.

Is there a way to detect the burst start? I want to play a sound when that happens.

I know I can get the array holding the burst events, but since they appear randomly and sometimes are omitted that does not help me much.

Hi @alexxUID, I have come across this issue myself and have found a solution. It’s not pretty but it works:

using UnityEngine;

namespace Example
{
    public class BurstAudioFeedbackExample : MonoBehaviour
    {
        [SerializeField] private ParticleSystem particle;
        [SerializeField] private AudioSource source;

        private int particleCount;

        private void Update()
        {
            // Play audio when the count is greater than internal value
            if (particle.particleCount > particleCount && !source.isPlaying)
                source.Play();

            // set internal value after check
            particleCount = particle.particleCount;
        }
    }
}

In a nutshell, it will play the audio before updating an internal count, meaning every time a burst (increase in particle count) occurs, the audio will play.

Hopefully, someone has a better method.

In the end I haven’t used the sound at all but the only solution to me seemed creating the bursts myself via script at runtime with ParticleSystem.EmissionModule.SetBurst