Best Way To Switch Levels?

Hi

So I am trying to make a sequence for my game where it opens to the main menu level and when you click new game it will play the intro text which is in another level. Currently I just use open level(by name) which works fine but when I switch from the intro text level to the playable level the playable one starts untextured for a little as it loads. What would be the best way of switching levels that would work when i add more. I am trying to understand level streaming and the use of a loading screen but dont understand how to do this. Also if I use level streaming how would I switch gamemodes since my main menu uses its own gamemode.

1 Like

With level streaming, you have one main level ( called the persistent ) which is usually empty, apart from the things you want in all levels ( lighting, fog etc ).

You then ‘stream’ levels into that persistent level. They just load ‘on top of’ it. You can do this using streaming volumes ( overlap boxes ), or blueprint to control when things happen. Nodes like

What can be a downside with this method, is the level is just added in one place, it’s default world position.

Another way, which I personally find more handy, is loading level instances, with these nodes

The reference they give you can be used to unload

With level instances, you can load them in any transform, and more than once if you want.

You still have a persistent, and you still load into that, but it’s more flexible.

So for your scenario, it would go like this

Open level persistent ( or it’s the default level )

Stream the level with your menu ( or just put the widget on the screen )

While the widget is showing, stream another level in the background

When it’s ready just remove the widget

Boom, done.

Of course, if you stream something while the game is running, the player can just see it happening. How you get around this is up to you, options are portals, loading behind a wall / door etc.

Regarding your game mode, unless I’m mistaken, I don’t think you can change game modes. The persistent holds the game mode, and you’re pretty much stuck with it. Ways to mitigate that usually involve having a more generic GM. For instance, if you want to have different types of players, then don’t put that in the game mode, but control the spawning of the player yourself from a custom controller.

2 Likes

So which is better In terms of overall performance(such as gpu performance) as I introduce more levels that need to be loaded. Level streaming seems like it would be as they are always loaded in some sort of way whereas instances are created when you call the node right?

1 Like

None, really. If you have to load X amount of things, you have to load X things whether you do it with ‘open level’ or streaming.

It’s not an efficiency thing, it a way of loading without the player knowing it’s happening, or interleaving things like loading behind a menu. That sort of thing.

Also, I might point out, if you have an open world type scenario, then you can just use world partition, which is another way of doing things.

PS: After packaging, levels will load much more quickly ( because everything’s been optimized ). Depending on what you need, ‘open level’ might do the trick.