I want to play a music track on the background of my game, and since my levels are pretty short it would be nice if the music didn’t restart every time a new level is loaded. How would I approach this?
Currently I load new levels with the following code:
I’m not sure how to implement a Persistent level, do I create an empty level where I only add an ambient sound actor and load my menu level from there?
Does this mean I need to setup level steaming for each of my levels? (via blueprints)
You can go into the Levels Window in the Editor and add map file together under a persistent Map. Make sure that you remove anything from the Persistent level that you do not want in your game. You can then control the level streaming using either blueprint or code. Essentially what you will be doing is loading the persistent level at the beginning of your game and then loading and unloading the other maps as you need.
Ok, I’ve been trying all day but unreal just seems to crash with the following error:
So I created a new map(lets call it base), completly empty except for the ambiant sound actor. In the level window i’ve added all my levels and turned them invisible. I’ve set my mainmenu map to load on startup and be visible. In the base level blueprint I have the following for testing purposes:
Now, when I run this it seems to crash the unreal editor on the unload streaming level node with the error above. (The first level is loaded correctly, but the mainmenu actors are still loaded, which is why I want to unload them.)
I think that this may be an error created by using both C++ and Blueprints in the Level Streaming process. And to clarify from your above image you have three levels referenced here. A Base level (base.umap), Minimal_Default.umap and MainMenu.umap Is that correct?
Are you using UMG, by any chance? If so, you need to delete any viewport widgets before streaming or moving between levels (that is, unless Epic fixed that already)
I think that this may be an error created by using both C++ and Blueprints in the Level Streaming process.
As far as I know I’m not loading any levels in C++ anymore.
And to clarify from your above image you have three levels referenced here. A Base level (base.umap), Minimal_Default.umap and MainMenu.umap Is that correct?
Correct, Minimal_Default is really the first level which I havent renamed yet, and MainMenu is just a looping Matinee scene that acts as a background for the title screen.
Can the continuous music play be done without level streaming, using just open level function?
I’m doing all savegame and level switches in HUD blueprint.