How to load a map from a dynamic level

Holy ■■■■, I took out all of that mounting stuff and this worked. So how would you handle a user downloading this information? Would you zip up the “DLC” project and then have the game at runtime download that zip file, unzip it, and mount it like this? Instead of using pakfiles?

Oh wow! So I took everything else out and just put in the code you used and it worked fine in the editor. It’s not working on a packaged build though, did you experience this? Also, I know you mentioned having users download the content. Did you just host a zip of the “DLC” project on a server and have them download that and unzip it then mount it with this method? Thanks a bunch.

I think you’ve lost me haha. If I cook the content and pack it with UnrealPak.exe then I get a .pak file in return. And if I try to mount with the pak file then it can’t find the map again.

I have DestProj and SourceProj. I gotta somehow get a map from SourceProj to be loaded into DestProj at runtime on a packaged build (this will be done by downloading the content but for now it is just sitting on another part of my computer). What you sent me with mounting the content directory of the SourceProj to the game directory of DestProj is working great in the editor. I’m just not sure how to make it work if I package DestProj. When I package DestProj it tells me failed to resolve map.umap. I’m sorry if this is something simple I’m just missing. This has been a long week trying to do this and you are being incredibly helpful and I very much appreciate it.

Cool - if it’s working in the editor that’s a good sign :slight_smile: Have you “Cooked” the content and packed it with UnrealPak.exe? Yes I did that, I made zipped packages which could be downloaded and also had them embedding into BMP files that I attached to hidden PowerPoint slides in their presentations… I did have it working with packaged files using UnrealPak but in the end I just skipped that and unzipped the files directly to the harddrive - seemed a waste of cpu cycles to pack it twice…

yeah sorry that was a bit of a side track :slight_smile: Are you storing all the DestProj assets in the “/Game/” folder of the project? I couldn’t get it to find the assets in the newly mounted pak file unless I did that…

I used backslashes for the path, don’t know if it makes a difference though. That path should be the path to the pak file - so if you’ve packaged your PakSource into a .pak file - use the path to that file ending in a slash, but not including the .pak filename eg if it is at “D:\UE4\4.17\Packed\test.pak” - use “D:\UE4\4.17\Packed”

Yeah you’re right, that code I linked to is set up to just load the assets directly from disk rather than mount a loaded pack - I think I was loading the pak file from the commented out bit that starts with “FString StandardFilename(filename);” - try uncommenting that block to load the pack file…

No worries! Yeah I’m still calling it like this: LoadMap("test", "/Game/", "D:/UE4/4.17/PakSource/Content/"); and the map and materials are in that content folder. And then for my DestProj I have everything in D:/UE4/4.17/PakTest/Content/. Is “/Game/” different from that base content folder?

Okay, so here are the steps I’m doing which I got from [someone else (mfish’s comment on the first answer][1]).

  1. Package the PakSource project using the editor.
  2. Locate the PakList.txt file in UE4 appdata
  3. In cmd, run UnrealPak.exe "D:\Paks\test.pak" -Create="path to that PakList.txt file"
  4. That will generate the pakfile and store it in “D:\Paks”

LoadMap function

bool AMyPawn::LoadMap(const FString& levelname, const FString& mountPoint, const FString& mountPath)
{
    FString ln;
    if (mountPoint.Len()>0 && mountPath.Len()>0) {
            FPackageName::RegisterMountPoint(mountPoint, mountPath);
	ln = levelname;
}
else {
	ln = levelname;
}

FName level(*ln);
UGameplayStatics::OpenLevel(GetWorld(), level);

return true;
}

Calling

LoadMap("■■■■■■", "/Game/", "D:\\paks\\");

Gives me this output in the logfile with a crash: SearchForPackageOnDisk took 0.015s, but failed to resolve ■■■■■■.umap.

(■■■■■■ is the name of my map, i apologize for the profanity but it’s been a really frustrating week haha :D)
[1]: Loading Map from Pak at Runtime - Programming & Scripting - Unreal Engine Forums

So the steps I’m using to create a .pak file are the ones i found in this thread (mfish’s comment) Loading Map from Pak at Runtime - Programming & Scripting - Unreal Engine Forums

I’m then storing that pak file in D:\PAKS\test.pak

LoadMap function

bool AMyPawn::LoadMap(const FString& levelname, const FString& mountPoint, const FString& mountPath)
{
FString ln;
if (mountPoint.Len()>0 && mountPath.Len()>0) {
	FPackageName::RegisterMountPoint(mountPoint, mountPath);
	ln = levelname;
}
else {
	ln = levelname;
}

FName level(*ln);
UGameplayStatics::OpenLevel(GetWorld(), level);

return true;

}

Calling

LoadMap("testmap", "/Game/", "D:\\PAKS\\");

This crashes my game and in the log says: SearchForPackageOnDisk took 0.015s, but failed to resolve testmap.umap.

I’m not doing any sort of mounting of the pakfile outside of that loadmap function, should I be?

Okay so using that code it says it mounts the pakfile okay, because it prints “loaded and mounted, listening.” Then it prints all of the files/directories in the “/Game/” folder, and then it gives me “SearchForPackageOnDisk took 0.086s, but failed to resolve testmap.umap”

My function now looks like this: bool AMyPawn::LoadMap(const FString& filename, const FString& levelname, const F - Pastebin.com
And I am calling it like this: LoadMap("D:\\PAKS\\please.pak", "testmap", "/Game/", "D:\\PAKS\\");

This is where I get confused, because I don’t understand what mounting a pak file actually does. I imagine mounting creates a link between your mount point and your mount path to allow you to access those files, but everytime i mount a pak file, it is unable to find the assets inside of it. I really wish there was official documentation for this. Thank you again for continuing to help me by the way, you have no idea. I’ll buy you a beer or something if we can get this working lol.

When the log prints out everything in the /Game/ Directory, I see the files from PakSource:

LogTemp: Warning: Directory: /Game/PakSource
LogTemp: Warning: File: /Game/PakSource/AssetRegistry.bin
LogTemp: Warning: File: /Game/PakSource/CookedIniVersion.txt
LogTemp: Warning: File: /Game/PakSource/DevelopmentAssetRegistry.bin
LogTemp: Warning: File: /Game/PakSource/PakSource.uproject
LogTemp: Warning: Directory: /Game/PakSource/Config
LogTemp: Warning: File: /Game/PakSource/Config/DefaultEditor.ini
LogTemp: Warning: File: /Game/PakSource/Config/DefaultEngine.ini
LogTemp: Warning: File: /Game/PakSource/Config/DefaultGame.ini
LogTemp: Warning: Directory: /Game/PakSource/Content
LogTemp: Warning: File: /Game/PakSource/Content/maptest.uexp
LogTemp: Warning: File: /Game/PakSource/Content/maptest.umap
LogTemp: Warning: File: /Game/PakSource/Content/maptest_BuiltData.uasset
LogTemp: Warning: File: /Game/PakSource/Content/maptest_BuiltData.ubulk
LogTemp: Warning: File: /Game/PakSource/Content/maptest_BuiltData.uexp
LogTemp: Warning: File: /Game/PakSource/Content/test.uasset
LogTemp: Warning: File: /Game/PakSource/Content/test.uexp

Your pack file is a zip (you can set it to be compressed). Suspect it doesn’t matter what it’s called. I host mine on s3 and download via http in app.

Hoping you get all the nooks and crannies sorted - would be amazing if you could post the final code as while I do a LOT of downloading I have yet to mount a umap.

If either of you is interested in helping out in my project I have an aim to turn it into a UE4 plugin that allows advanced users to add gameplay to my shipped product… And we’re going to do it in the name of something good - building an education platform giving users a taste of UE4 technology while they learn…

Cool, it looks like that bit’s working ok…
I notice in the dir listing it shows “maptest.umap” rather than “testmap.umap” - could it be that?
No problem, I’m happy to help get to the bottom of this :slight_smile: I’ll have a beer to celebrate once it’s working :slight_smile:

I put some source code out there to help downloading from AWS s3, long rambling thread here: Downloading Content Dynamically - World Creation - Epic Developer Community Forums

Probably not quite the state of the art and these days you should be able to find plugins or use the AWS C++ SDK that didn’t exist when I was going through this.

Going back the question of “cooking” I suspect you’ll need your content to be built for either the editor or shipping product and there will be two different pak files. However seem to remember finding that it would crash on incorrect content rather than fail to find it. Memories from two years ago are a bit faded though.

Yeah my goal is that when I finally get this figured out I’ll save out the important parts and write a tutorial about it or something. Because there is pretty much 0 information on how the heck to do this which is very weird because this seems like it would be a very common thing.

No that’s not it, it should say testmap.umap, the actual map name is quite vulgar due to my frustrations and I figured it would be more appropriate to swap it out to something else haha. That’s my typo. If it’s in the “/Game/” directory, I don’t understand why it wouldnt be able to find it.

Awesome, thank you for that. I’ll see what happens when I get to that point haha. Hopefully it’s soon!

Whenever I package either project I turn on “For Distribution” and package for WindowsNoEditor so I think that’s covered. It only crashes when I mount onto /Game/ and try to change levels because when it can’t find the mounted level, /Game/ has essentially been overwritten by the mounted files so it crashes when it can’t reload the start map.