- Home /
Question by
coheebuzz · Apr 21, 2021 at 05:31 PM ·
audiosource
AudioSource stops after playing a sound 32 times
I have the following script which plays a short projectile sound when a particle is emitted which works well for the most part, the problem is that the AudioSource will stop after playing the sound 32 times in succession, as if it's not unloading the sounds after they have finished and is reaching the voice limit.
What am i doing wrong, is there another way to have an AudioSource repeat a projectile sound?
void Update()
{
if (Input.GetAxisRaw("Fire") != 0)
{
if (! gunParticleSystem.isEmitting) {
gunParticleSystem.Play();
}
count = gunParticleSystem.particleCount;
if(count> numberOfParticles && !audioSource.isPlaying) {
audioSource.Play();
}
numberOfParticles = count;
}
else
{
gunParticleSystem.Stop();
audioSource.Stop();
numberOfParticles = 0;
}
}
Comment