Sound doesn’t loop properly



  • I have imported a loopable wav file and I start the sound and directly call it again and again once finished but when it finished the furst time there is a small lag (silence for a few miliseconds) and then it starts from the beginning. This is only at the first end. After the second end it timely starts again without lag.



  • The same happens when connecting two play sound behaviours: the second should start immediately after the first has finished but there is always a lag before starting the second sound.



  • @lupo What is the sound? Is it music? Even if it's not, you could try using the Play Music behaviour in the Scene tab which has a loop option. You're right though you'd think there wouldn't be a delay since you haven't put any delay between them.

    Another option would be to find out the exact length of your sound and use a Timer with that length as its delay to play the sound. This way would work with your other post about high pitch sounds if you can figure out the exact duration.



  • @aidan-oxley Thanks for the hint. The sound is not music and a music is already playing. The sound is a car engine sound which increases the pitch if driving faster and lower if driving slower. So the idea with the timing needs to be calculated for all the possible steps which is very tedious.


  • Admin

    The problem is that by the time you trigger the behaviour again, there is a delay. Executing behaviours isn't instant. It takes a cpu cycle for it to trigger (or more depending on other behaivours) so this is what's causing the timing issue.

    I think @Hamed will need to add a loop function into the behaviour like we do with play music.



  • @murtaza But how do you explain that the delay always only happens after the first restart of the sound? Every subsequent restart is without any delay.


  • Admin

    @Hamed Have you seen this before?


  • Admin

    It sounds like you need the sound to preload the sound effect. A work around could be to play the sound with 0 volume initially that way its loaded into memory, and you can try playing it again later.