Save map at runtime

Hello,

In my game I have a map with a lot of actors. Now I want to save this map with all the properties of the actors along, whenever the user hits the save button in game. I have seen this function: FEditorFileUtils::SaveMap | Unreal Engine Documentation. But I cant get it to work (unresolved external symbols) and it is probably only for the editor. So is there an other way I can do this? Because why should I code a method for saving a map when you allready have one.

Greetings,

Hey mate,

did you checkout:

also rama did a nice wiki article:

ok, I can make a save game class with a uworld property, but how can i set the uworld?

By that I mean, how can I set the current rendered / used uworld, not the one of the save game class.

If a UWorld can be saved out (Havent tried that) then you could load your UWorld back in then get a handle to the current FWorldContext object and use WorldContext.SetCurrentWorld( YourWorld ); then GWorld = YourWorld. Thats what I used to set the current world in editor. But none of them are editor only functions, but no idea what it will do ingame.

ok, will try them and report.

Ok and how can I get the current WorldContext??

If you have a current world already loaded, you can use GEngine->GetWorldContextFromWorld( CurrentWorld ); or GetWorldContextFromWorldChecked( CurrentWorld ); which does additional checks im guessing. Otherwise you can use GEngine->GetWorldContexts( ); which returns an array of them, in standalone play there should only ever be one (Multiple simultaneous worlds are not supported in standalone). In editor there could be at least two (Editor world and PIE world).

Tried it and nothing happens. Did you do something else? Like telling the engine to load the new world.

Or do you know what the difference between the editor and game is in this respect?

Ok after looking in the save file, it only has the path to a temp folder with a map in it. Could I load a map in game?

Bump, really need an answer

nothing???

I suspect that if the above stuff did not work, then there is no way outside of the editor to save a umap outside of the editor. Im guessing due to the fact that when a game gets packaged, the files get cooked, which strips out a lot of metadata. Which cannot be done during runtime. You may want to look at saving out ur maps to a custom format. And when the world gets loaded. Load in your custom format map and spawn in the necessary actors.

Ok, is there a way then to save out actors, without having to save all properties manual (for example get an array with all properties)?

Serialize? This is already setup to serialize all actors properties that aren’t transient. So you could just bridge off that.