How does open-world games save maps?

I know how to save variables and stuff. What I’m wondering is, how to save maps as a whole? If you try to save the whole map as variables, it goes amazingly long. Does anyone know or have experience in this?

Why do you want to save the whole map? Do you mean saving all the geometry and terrain and the skysphere and literally EVERYTHING? Or do you just mean things like items, characters, etc.?

It’s open world, right? So there are a lot places. When a player solves a puzzle; for example opens lots of lights or moves things, when the player dies, I want to bring back all of those as they were. If I do it with variables, the list would be too long.

Hmm. I’m not sure how to approach that, but I would try to make every actor responsible for saving itself or feeding its save information into a master save manager object. Then you don’t have to make a list, you just fire off an event that all savable objects implement the interface for, and then they all send their save info to the manager (or save it themselves) and you’re done.

Likewise for loading, although this brings up the problem where what if the object was spawned or destroyed and that fact is what needs to be saved and restored? Not sure. Mathew Wadstein has a tutorial on saving objects and map changes that doesn’t involve building lists though, I think.

Yes that’s where it all gets confusing. I’m sure there is a system to save all map as it is.

If there is, I don’t know about it. That seems like a lot of data to save when you’re only going to use some of it.

Does anyone know?

The correct way way to handle open worlds is with these techniques/systems.


World Composition
Used to create a large landscape out of individual height map tiles.


Level Streaming
Used to load/unload components of levels as you enter/leave streaming volumes.


Instantiation
Independent levels used for sections of the game where the rest of the game is no longer visible and there is no reason to have it in memory. (IE The inside of a building, typically games like Skyrim, The Witcher, MMO’s, etc. do this for large buildings and dungeons because it significantly reduces the amount of unnecessary detail in the Open World.) There isn’t really anything you need to know about this, just “Open Level.”


There is sufficient information about all these subjects at the provided links.

World composition will have a main level where persistent information between tiles will be stored, and yes you have to store all information in the game instance or save game class, you cant just expect it to store this information for you. Otherwise you would be rewriting the level every time you played the game.

Short cuts you could use is have an actor/class type for quests/puzzles with a variable of its completion/progress inside the class. Then when you want to save the game or enter the level you can use foreachloop with get all actors of class and store these variables in an array associated withe the level in your game instance or save game class.

So, you solved a complicated puzzle and quit the game. When you re-open it, you check if the puzzle’s done before and if so, bring it to solved phase in the event begin play; is this how everything is done in open world games?

Open worlds are large filled with millions of variables. The easiest way to do what you want to do is categorically go through things with a foreachloop + get all actors of class when you enter a level and have them cast to the game instance to update their current status manually in real time.

Thank you for your answer, appreciate it.

Yeah, you can look into serialization, but in most games its optimal just to remember a handful of variables. When you’re in a load screen of a game this is what it’s doing, it’s cycling through arrays opening/closing locking/unlocking doors after it loads the default world. In procedurally generated worlds it will just load an empty world and build the surrounding area entirely in the load screen.

If your world has as many variables as something like minecraft you make arrays of arrays(chunks) so you aren’t constantly checking through the entire world for information about the specific area you are in. You will need to incorporate efficient algorithmic design. Creating regional arrays. (IE: an Integer array for quests progress or door status in one area of your game.)

Just like you don’t know what the weather on the opposite side of the planet is, you will likely not need to load everything about the entire world at once. That’s where learning about the things I posted in my answer will help you significantly.

Thank you for your detailed answer. It helps a lot.