Music looping to specific point

Krayfishkarl
Tue, 27 Jun 2017 18:09:22 +0000
Audio

So my game features music tracks that loop, but not to the very beginning. Instead to a specific point in a song. Like for example, a song that I play might restart back at the 5 second mark at around 120 second mark, just before the end of the sound file. Basically, playing the song’s intro only once, and stopping before the ending plays without having to chop up the sound file into multiple smaller files.

In Blueprints, I have it set on a timer that loops every 0.01 seconds, and increments a float value by 0.01 which I’m calling “Overworld Music Time”. I also have a data table that contains float values for the loop back point of every song as well as what point in the song it should loop from. So when “Overworld Music Time” reaches the specified point in the song, it stops the audio file, and plays it again from the loop point. This works just fine except for one thing.

The problem is that “Overworld Music Time” does not increment when the game is paused. To my understanding, timers don’t run when the game is paused, but what might an alternative solution be? I could get around this entirely by just stopping the music when the game is paused, but I don’t want to have to do that.

What’s a good way to get timers to run while the game is paused? Or better yet, does UE4 have any built-in system of this sort of music looping that I’ve somehow missed?

6 posts - 3 participants