How can I get music to play continuously from the main menu into a level and back to the main menu?

I’ve tried a few different strategies from seeing YouTube tutorials on this. Problem is my main menu is on a separate game mode. So if I try storing a global variable of that it gets overridden when a new game mode is loaded in my regular levels.

I’ve also tried putting the main menu in the same game mode as my levels. But then I run into issues where the game instance object with my music seems to just disappear after ~45 seconds. So my music just randomly stops after 45 seconds.

Levels right now are chosen from the main menu but I can put a level section menu in game but that’s more of a pain.

Would persistent levels solve this problem?

Anyone have an idea on how I could get a playlist of music to continuously play without interruption from the main menu until the game is exited? I just want the music to shuffle each time the game is loaded up.

Starting it from the game instance should do the trick.

You can also have a persistent level from which you stream all the other levels you want to load. Notice ‘stream’, not ‘load’. Then play from that level.

But like I say, GI should do the trick. What makes you think the GI is dissapearing? Because you would have no game if that was the case…

Thank you so much for the reply!

Yeah, that’s what I thought too but the music just seems to cut out ~45 seconds in when nothing is going on. I’m having a hard time understanding why or how to debug that. All other sounds work fine.

Before the cut out issues, I would run into issues with the GameInstance being recreated when going back to the main menu as it seems like it was re-initialized in the new MainMenu level that loaded in. That caused the music to restart. Does sound right?

You only have one GI running the whole time the game is running. It doesn’t get changed.

Is the audio track definitely longer than this?

Yeah, the audio tracks are 2-3 minutes long each. I’ve triple checked the length of them. I guess I’ll try converting everything to a Streaming workflow with persistent levels. The music would usually get choppy sometimes during big level loads which streaming may fix as well…

You can use the GI without converting to streaming, btw :wink: