Download

Loading Levels in a RPG

So, from what I can tell there is two ways we can transition between levels.

Method 1: We start in one level and then using ‘Open Level’ open an entirely new map.

Method 2: We have a persistent level and streaming levels, and we load the streaming ones into the persistent level.

My issue is, I have a main game map, and occasionally the player encounters a monster and then enters into a battle mode.

My first instinct was to create two different levels one for the main game and one for the battle level. Each with their own game mode, state, ect, since they logically should. Since the Game Mode dictates the rules of the game, and they are different when in the Main Game than in the Battle mode.

However, the only way to do that is to use method 1 above. I would make the first level have a ‘MainGameMode’ and the second level a ‘BattleGameMode’, and using Open level they will transition successfully. However, in this scenario, how do I keep my data UObjects alive between level transitions? I don’t want to have to save to file and load in the next level.

If I do level streaming, it appears to be only possible to have one Game mode in that way (which makes sense). I could put everything in the same Game mode, but it would be nice to keep things more logically separate.

Whats the best way to handle this? Is there any way to persist UObjects between levels safely?

And a little left field, but is there a way to animate a transition between two levels?

Ooo…

Came here to post the EXACT same question (for a slightly different purpose).

Our game has four choices of character to play, these four choices are also allowed upon ‘death’.

My initial thought was to have the char select ‘room’ on the map but hidden away, however this would require EVERY map to have these assets and would be a waste of resources.
I was coming to ask if there is a way to preserve the ‘states’ of the objects of a particular map while the player is on the char select map.

Sorry I have responded with no solutions, if I find anything that may help us I will post them up here.

Would love input from UE4 pros tho.

I would suggest thinking about ways to tie Method 1 more seamlessly into what you have/want.

You say you don’t want to deal with saving to file and loading the next level, but in my opinion these transitions to/from battles present an opportune time for a quicksave. (edited to add: I assume since you’re making an RPG that you are going to have to work on saving the game at some point, if that’s your fear - go ahead and tackle it now and you can ensure it continues to work as you add to the game, this will make your life easier.) You could use a transition (depending on what kind of game you’re making, a quick intro for the people in the fight etc) while you quicksave and unload the main level in the background and fire up the battle mode, at the end of this when you were putting up score/inventory whatever else, you would save off the results of the fight (however you do that, perhaps just a quicksave again from the battlemode), and then reload your quicksave as you transition back out into the main game. This also means that if you happen to crash loading or unloading between a fight you shouldn’t go back very far (it’d also make savescumming a snap!)

Instead of trying to reinvent the wheel I would approach it more from the perspective of working within the methods available, and if you don’t like the way that looks or feels then you can hide it in the background and make whatever sort of transition you’d like to in the front (you could probably set up a matinee sequence between the two states to hide them in ‘cutscenes’ of a sort, maybe even just a panning of the battle ‘field’.)

Its definitely a possibility if I have to, but I was hoping there might be a more graceful way. Saving isn’t so bad, but having to load the whole object tree each time is silly, it should only have to load from a file once.

Why not have a Persistent Level and two child maps: Adventure and Battle. When a Battle is triggered, draw an animated material while the second child map loads in and then switch to another player character (Or transport your current Player [Depending on what you wanted to do].

Alternatively, you could have one map and have the Battle map (With a small Skybox) UNDER the terrain of your normal map, and again when a battle is triggered, draw a full-screen material while the player teleports to the second area. Better yet, you could have another Player Character waiting to be possessed in the Battle area?

I wrote about “Loading” screen (Drawing Material HUD) while the game loads in my free book, if you want to check it out: E-Book - Master the Art of Blueprints - Google Drive

Did not know we could do ‘child maps’, I will have to research this! Pointers always welcome…

Thanks Kitatus

Well a Child of Persistent level, but it’s a Child none-the-less. Literally this video is all you need:

Enjoy!

Wow.

I just found this vid in a diff thread and came here to post about it.

Thanks a ton Kitatus, you are a million steps ahead of me.

Nah, I’m no further than you, I just focus my UE4 time on helping as many people as I can! If you have anymore questions, I’ll try my best to answer them!

I decided with going the Persistent route, and having a MasterGameMode, hold UObjects with logic for various other game modes, such as BattleMode ect. That way I can still logically separate the code to some degree and it doesn’t become a nightmare giant game mode. Now when I stream various levels, I just use the correct child node for logic for that map.

–edit–

I did find some useful information for people who do not want to use Persistent / Level Streaming:
https://answers.unrealengine.com/questions/28278/where-to-store-global-variables.html

There is apparently a GameSingleton class that you can create and expose in blueprints. I haven’t checked to see if it survives Level transitions, but based on the description I assume it does.