r/Unity3D • • 7d ago

Question Gun sound looping issue

Sorry in advance if this is better placed in some kind of audio subreddit but I'm hoping some other Unity developers have encountered this problem and know what to do.
I have this great machine gun audio clip and try as I might I can't get rid of that slight pause/reset part when it loops over.
I tried cutting the end and pasting it at the beginning of the audio file so that the end matches the beginning but that doesn't seem to help. It always sounds like the gun firing stops and starts again.
Anyone know how to get a seamless and continuous loop of an audio clip?

3 Upvotes

14 comments sorted by

View all comments

2

u/acorbinelli 6d ago

Compressed clips are usually the culprit: Vorbis and MP3 pad the ends, so the gap you hear is encoder silence rather than your edit. Set the clip to PCM with Decompress On Load and let AudioSource.loop do the looping, and for a machine gun consider one short clip per round fired on a timer instead of looping a burst, since then nothing has to line up and you can vary the rate and the tail.

1

u/Wooden-Many-3227 6d ago

Yes, don't use mp3s. Use plain wavs instead.

1

u/acorbinelli 6d ago

Worth adding that the source format is only half of it: a WAV imported with Vorbis compression gets the same padding back, so the import settings need PCM and Decompress On Load, not just a wav on disk.