Save procedural generated map as *.umap?

Hey folks,

I want to create some procedural generated maps so that I can save time to manual create levels. But that can only work for me if I’m able to save these maps after generation.

How I plan to do that:

  • Create workflow for procedural generation
  • Run the game which automatically runs the workflow
  • Save the procedural generated map as *.umap so I can use it to expand/place stuff on it

The first two points will work for sure but I don’t know if it is possible to save the procedural generated map as *.umap during runtime / or if it is even possible at all with UE4.

Why do you want to generate them in game?
Do this in level editor.

To generate ‘unlimited’ maps and use the level streaming feature to get a better environment / world that can expand over time.

Only editor modules can generate assets.

So I couldn’t just run:

UEditorLoadingAndSavingUtils::NewMapFromTemplate(const FString & PathToTemplateLevel, bool bSaveExistingMap) 

  1. run my generation functions and after that run

UEditorLoadingAndSavingUtils::SaveMap(UWorld * World, const FString & AssetPath)

If you want to do that in Editor, that’s fine.
That can’t be done in packaged games tho. If you want to do that in shipped games you need a custom map serializer, Unreal has a built-in JSON module that works in runtime modules and you could save any info to Json format and write/read that to/from a text file.

Okay, good to know.
Do you have a link to that module?

You don’t even need to get that far, if all you want is save some data like which models and their locations, you can just create a custom struct or UObject class and serialize it to disk. Easier to use than dealing with json serialization.

Depends, I worked with json often so it isn’t a big deal for me.

It’s in Json folder from Runtime source code: Runtime/Json/Public/Dom/JsonObject.h

How exactly would I do this?
I can’t spawn actors during the construction script (tested it):

[2019.07.12-19.58.19:404][537]LogSpawn: Warning: SpawnActor failed because we are running a ConstructionScript (Actor)