x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to load a map from a dynamic level

Hi,

I've managed to dynamically load a pak with FCoreDelegates::OnMountPak.Execute() but it fails when I try and load a map from it.

I've tried ServerTravel and UGameplayStatics::OpenLevel - OpenLevel returns an error that the map cannot be found - the map is specified as the name returned when I look at it's reference from the editor (e.g. /Game/MyMap.MyMap).

Has anyone found any useful documentation on doing this, or have any clues as to what could be going wrong?

Thanks,

Richard.

Product Version: UE 4.10
Tags:
more ▼

asked Jan 21 '16 at 05:24 PM in C++ Programming

avatar image

RichardB
134 3 4 11

avatar image RichardB Jan 22 '16 at 06:30 PM

Is there someone at Epic that can help me with this please?

avatar image RichardB Jan 28 '16 at 10:56 PM

After seeing an example where an asset was being loaded with a "StaticMesh''" wrapper I found that "Copy Reference to clipboard" provides something similar to World'/Game/MyMap.MyMap'. I plugged that into my code but the results are the same - OpenLevel has no return code so can't tell if it has failed apart from the fact that UE is still displaying the old levels map. Anyone?

avatar image RichardB Jan 31 '16 at 09:28 PM

Hi again if anyone is reading..

Some more information provided:

Saving a map to the base project and loading that with UGameplayStatics::OpenLevel works fine.

Either "World'/Game/MyMap.MyMap'" or "MyMap" appear to work.

When attempting to load the dynamically loaded pak file it looks like it's trying to load - it creates a new UWorld and a new GameMode - calls the GameMode::InitGame method. Querying the new World returns the base projects Map name though and the old map is still displaying. The log file tells me that it has loaded, no error entries.

avatar image RichardB Jan 31 '16 at 10:11 PM

Update:

I had my Oculus Rift plugged into the HDMI but not USB, I unplugged the HDMI and now I am getting error messages about not finding the map in the log file - most strange, but also much more helpful - Still, I've tried all incantations of the map name and it still does not find it.

avatar image RichardB Jan 31 '16 at 10:19 PM

Ok, looks like the level name takes on the base games hierarchy? I specify the level name now as "/Game/BaseGame.newlevel" and it appears to load and then exit - at least it's progress...

avatar image RichardB Jan 31 '16 at 10:59 PM

Still stuck.. I get this error now:

LogPackageName: SearchForPackageOnDisk took 0.018s, but failed to resolve MyMap.umap.

avatar image RichardB Feb 03 '16 at 09:42 PM

It appears that /Game/ is mapped to the original game still, so when specifying /Game/SubMap.umap it's mapping it to "../../../LauncherGame/Content/".

Using just the "SubMap" name gets through the path finding routines but then barfs later with that "failed to resolve" error. It sounds like short-names are not supported in standalone anyway.

I even tried laying out the map and data in my dynamic pak into the same folder hierarchy and names as the launcher project but that doesn't work either.

sigh...

avatar image theonecalledtom May 03 '18 at 04:02 AM

Branching down to a more sensible width....

@TestyRabbit I'm including a file with my full pak file mount code. This allows me to read raw files from the pak file. I'm not saying it will fix your problems but thought it might be worth adding here.

Question: Can you load a file - for instance use the file system to load that umap into memory? Sorry if I missed you being able to do this, the thread above is EPIC.link text

dlcmounting.txt (3.2 kB)
avatar image TestyRabbit May 03 '18 at 04:10 AM

I'll give it a shot now and let you know. By load the umap into memory do you mean try to open it?

avatar image theonecalledtom May 03 '18 at 04:32 AM

Yeah - using something like FFileHelper::LoadFileToArray.

avatar image TestyRabbit May 03 '18 at 05:32 AM

Whjat is this? Warning: This code is not running the Matchoo modified UE4 engine and will not work in packaged builds (should work for development)

avatar image TestyRabbit May 03 '18 at 06:21 AM

@theonecalledtom

So I added in your code and just tried calling OpenLevel(GetWorld(), "maptest") and it actually opened the world in the cooked build!! It gave me an issue about not being able to find the material though :/

LogStreaming: Error: Couldn't find file for package /Game/test requested by async loading code. NameToLoad: /Game/test
LogStreaming: Error: Found 1 dependent packages...
LogStreaming: Error: /DLC/PakSource/Content/maptest

I can send you the whole log file too if you would like

avatar image theonecalledtom May 03 '18 at 06:49 AM

That was an improvement then?

The logfile might be interesting. The error line you hit is because of a problem where an optimization stopped the file system loading data from lower file systems once you have mounted a pak file of dlc on top (which my code does). I put a pull request in about 4.15 but they didn't approve of my solution so it's not mainstream (I haven't looked to see if an alternative exists in more recent builds as I'm still on 4.17).

avatar image TestyRabbit May 03 '18 at 07:14 AM

It actually works and finds the material if I remove all of the unnecessary stuff from the pakfile and then mount it onto "/Game/" here:

 StandardFilename = "/Game/";
 if (!mp_DLCPakFiles->Mount(*rPakFileName, 0, *StandardFilename))

I have attached the logfile for if it can't find the material (when I mount to the actual StandardFileName -- D:/PAKS/ -- instead of overwriting it with /Game/ using your sent code).link text

Mounting it ontop of "/Game/" works but it then overwrites all of my actual game files so that's not really doable. Any thoughts?

paktest.log (26.6 kB)
avatar image TestyRabbit May 03 '18 at 07:21 AM

It seems it's always looking for the material at /Game/material instead of using the mount location. Could this be a bug Unreal engine?

avatar image TestyRabbit May 03 '18 at 08:07 AM

Okay, I have figured out a way to kind of spoof the pakfile into getting to the real path. I will type out an example I just tested.

  • I have a destination project located at D:\Projects\DestinationProj\ (The project I want to mount my pakfile in)

  • I have a source project located at D:\Projects\SourceProj\ (The project that I'm using to build my pakfile)

  • In my source project, all assets used in the map are in a subfolder called Map. So the directory is D:\Projects\SourceProj\Content\Map\<assets here>. NOTE: The map itself goes in the root content folder, i havent tested with it anywhere else but it probably would work.

  • In order to get my pakfile, I must package my Source project.

  • After packaging, I'm left with a txt file in C:\Users\<username>\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+Program+Files+Epic+Games+UE_4.17 called PakList_SourceProj-WindowsNoEditor.txt

  • I copy that txt file to an easier to access location and rename it. Now it is at D:\Paks\Paklist.txt

  • I open Paklist.txt to edit, removing all lines that don't start with D:\Projects\SourceProj\Saved\Cooked\WindowsNoEditor\SourceProj\Content\...

  • Each asset in the .txt file is made up of two strings, ie D:\Projects\SourceProj\Saved\Cooked\WindowsNoEditor\SourceProj\Content\material.uasset and then to the right is ../../../SourceProj/Content/Map/material.uasset

  • Remove Map from the path on the right for each asset that is remaining

  • Save and close the .txt file.

  • In command prompt, run UnrealPak.exe D:\Paks\testpak.pak -Create="D:\Paks\paklist.txt". This will generate a pakfile that you will be mounting. Now you have a pakfile located at D:\Paks\testpak.pak

  • Using the code you sent me, I mount the pakfile to "/Game/Map/" (mp_DLCPakFiles->Mount(*rPakFileName, 0, TEXT("/Game/Map/")). And then I try open the map using UGameplayStatics::OpenLevel(GetWorld(), mapname);.

  • I package the DestinationProj and run it.

  • Map is loaded with assets.

avatar image RichardB May 03 '18 at 06:33 PM

Excellent - so it's working? Does that also work just using the non- DLC map load as well?

avatar image TestyRabbit May 03 '18 at 06:48 PM

I just tried it with the code @theonecalledtom sent me. I think the reason his code works is because he mounts the pack somewhere, and then mounts wherever he mounted the pak to game folder. So say he mounts the pak to D:\MountPak\ , then he mounts D:\MountPak\ to /DLC/ and now all of assets are under /DLC/. I think the right side of that paklist.txt file is basically just the path after mounting to the asset, and since it seems that UE4 doesn't automatically fix that for you, you can just do it yourself and it will work. So I imagine you could mount it wherever you wanted as long as the paths in the pakfile are the same.

avatar image RichardB May 03 '18 at 07:09 PM

Right, that's cool - sounds like it fixes the problem that lead me to putting the files in the root of D:... I think I'm still going to try to get it working stock in 4.19 to see what happens in there out of curiosity... Glad to hear you have a working solution :)

avatar image TestyRabbit May 03 '18 at 07:15 PM

Yeah that's a good idea. I might do the same once I finish this contract because I think it would be really cool to write a plugin that handles this stuff for you. Or at least document how it's done because there is no information. That's why I wrote that step by step up there so I don't forget lol. I imagine it's a pretty requested feature. someone sent me information about using the OnMountPak.Execute() so im going to give it a shot now.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

5 answers: sort voted first

There's a function you can call to mount a pak to a root path (/game, /engine etc). Away from computer at the moment but I found it when searching the engine code for an error about root names.

The comments implied that use of this would allow you to override existing asset access with new assets. As soon as I called it the engine mounted assets in my pak and I've been able to load utextures and usoundcues using short paths - including in standalone builds.

more ▼

answered Feb 04 '16 at 05:18 AM

avatar image

theonecalledtom
1.3k 61 68 271

avatar image theonecalledtom Feb 04 '16 at 05:26 AM

Might not help you but here's the code I've got to mount pak files (not tested umaps yet). The first few lines are setting the mount point to the pak file location so files can be pathed relative to that - MakeStandardFilename is very important in the approach I take - the internal pak file directory structure is quite sensitive to paths.

RegisterMountPoint makes my files accessible using the short file names. In this case a filename of a/b/c.uasset within the pak would become /dlc/a/b/c

The output after has proven useful while working through my own pak file woes, so I've included it here.

     FString StandardFilename(rPakFileName);
     FPaths::MakeStandardFilename(StandardFilename);
     StandardFilename = FPaths::GetPath(StandardFilename);
     
     if (!mp_DLCPakFiles->Mount(*rPakFileName, 0, *StandardFilename))//DLCPakMountPoint))
     {
         Errorf(_T("DLC - Unable to mount pak file '%s' to '%s'"), *rPakFileName, *StandardFilename);
         return false;
     }
 
     FPackageName::RegisterMountPoint("/DLC/", StandardFilename);
     //TODO UnRegisterMountPoint
 
 #if MM_DEBUGrPakFileName
     struct Dump : public IPlatformFile::FDirectoryVisitor
     {
         virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory)
         {
             if (bIsDirectory)
             {
                 Outputf(_T("Directory: %s"), FilenameOrDirectory);
             }
             else
             {
                 Outputf(_T("File: %s"), FilenameOrDirectory);
             }
             return true;
         }
     };
     Dump visitor;
     mp_DLCPakFiles->IterateDirectoryRecursively(*StandardFilename, visitor);
 #endif

avatar image RichardB Feb 05 '16 at 09:44 PM

Thanks this helps a lot!

The FPackageName::RegisterMountPoint() was what I was missing.

So far adding that to my code I can now load maps ok but the assets contained in the maps.. not so much... will keep working on that.

The Mount point from what I can tell is the original file location of the pak contents rather than the location of the created pak file - this may be because I'm loading a pak with FCoreDelegates::OnMountPak.Execute(). Is your mp_DLCPakFiles a folder on disk?

I also noted that if I have a uasset file located on disk at the location I add for the MountPoint, it will load that asset before checking the mounted pak file - that ones a bit of a trap...

Will keep working on the asset loading... Thanks.

avatar image TestyRabbit May 01 '18 at 08:19 PM

Hey RichardB, I know this is a couple years old but I was wondering if you ever managed to get the assets in the map loading as well? I'm struggling with this right now

avatar image RichardB May 01 '18 at 10:46 PM

Hi TestyRabbit. Yeah I did get it working - I've attached a link to the sourcecode I used (there are a lot of commented out bits from various attempts but it successfully loads maps and assets... The link for the cpp file is: http://r4nc1d.com/files/deepHelpers.cpp - the LoadMap() function is the one with the important bits in it, I call it from my app with LoadMap("Footprints","/Game/","c:\Program Files (x86)\Slidescape\Content\Scenes\Deep\Footprints\") The assets all have to be cooked first, and then packaged with the Unreal Package program UnrealPak.exe...

avatar image TestyRabbit May 02 '18 at 01:07 PM

Holy cow you're a lifesaver. I'm working on some other stuff but I'll have to take a look at this tomorrow. Thank you, if I have questions I may reach out if that's alright. this has been a real big bitch haha.

avatar image TestyRabbit May 02 '18 at 03:02 PM

So I'm looking through this file you sent me, it seems the only thing not commented out is essentially this block here:

 bool triggerLevelLoad = true;
 FString triggerLevelName = levelname;

 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);

This does all of it?

When it comes to mounting, did you use the FCoreDelegates approach? Because my issue with that approach is that after I mount the pak with that, it is unable to resolve the map name. If I use the PakFile approach I'm able to find the map but all of the assets are gone.

This is the path that my map is at in the pakfile: USETHIS/Content/test.umap (The visitor prints this out). Does that mean that I would call it like this?` LoadMap("test", "/Game/", "D:\\UE4\\4.17\\USETHIS\\Content");`, I'm trying to load the map into a project called "PakTest" located at "D:\\UE4\\4.17\\PakTest\\"

avatar image RichardB May 02 '18 at 08:31 PM

Yeah that's the bits that are needed - the rest is experiments, I did this a number of years ago so it's a bit foggy but I do remember having the same issue with the FCoreDelegates approach even though there were a number of people recommending it. This was the only way I could get the maps and all assets to load. I also remember trying to use a separate folder like "USETHIS" but that didn't work for me either so I stuck with "/Game/" and made sure all assets were within that folder (or subfolder). If your map is called "test" and the folder it resides in is "D:\UE4\4.17\" those should be the parameters - so it would be LoadMap("test","/Game/","D:\UE4\4.17\");

avatar image TestyRabbit May 02 '18 at 09:16 PM

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.

avatar image theonecalledtom May 03 '18 at 12:10 AM

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....

avatar image TestyRabbit May 03 '18 at 12:13 AM

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.

avatar image theonecalledtom May 03 '18 at 12:17 AM

I put some source code out there to help downloading from AWS s3, long rambling thread here: https://answers.unrealengine.com/questions/355615/downloading-content-dynamically.html

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.

avatar image TestyRabbit May 03 '18 at 12:20 AM

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

avatar image RichardB May 03 '18 at 12:30 AM

Yeah I had some similar thoughts when working on these routines - I reckon that it will work really well! Happy to hear you're working on it! :)

avatar image TestyRabbit May 03 '18 at 03:04 AM

WORMHOLE FROM DEEP THREAD

Which pack list do you mean? In the game when I log it using PakPlatform->IterateDirectoryRecursively() it prints this:

 LogTemp: Warning: File: /Game/maptest.umap
 LogTemp: Warning: File: /Game/test.uasset

And when I list out the pakfile in the command line using UnrealPak.exe D:\PAKS\test.pak -List it prints this:

 LogPakFile: Display: Mount point D:/UE4/4.17/PakSource/Content/
 LogPakFile: Display: "maptest.umap" offset: 0, size: 749458 bytes, sha1: 2F0B6BDD8AFCBFD10B3BEA083D5058B1718229E9.
 LogPakFile: Display: "test.uasset" offset: 749511, size: 99694 bytes, sha1: 3CF6D36A4E575D523AC70A42FB15191389E84011.
 LogPakFile: Display: 2 files (849152 bytes), (849152 filtered bytes).
 LogPakFile: Display: Unreal pak executed in 0.001153 seconds
avatar image RichardB May 03 '18 at 03:22 AM

When I list one of my pak files I get a somewhat more "packaged" set of files - are you sure that you've Packaged the files for WindowsNoEditor? Here's a subset of my list:

LogPaths: Warning: No paths for game localization data were specifed in the game configuration. LogInit: Warning: No paths for engine localization data were specifed in the engine configuration. LogPakFile: Display: Mount point ../../../ LogPakFile: Display: "Engine/Content/Functions/Engine_MaterialFunctions01/Opacity/CameraDepthFade.uasset" offset: 0, size: 8757 bytes, sha1: 1D73CD0EDE4A4C73D19E40AB82DAC45A52FDD696. LogPakFile: Display: "Engine/Content/EngineMaterials/T_Default_Material_Grid_M.uasset" offset: 8810, size: 350605 bytes, sha1: A1B7EBD88C1B91591B048F3F004CB66E2190FF33.

LogPakFile: Display: "Engine/Content/Maps/Entry.umap" offset: 3056467, size: 11331 bytes, sha1: B5EB6D806419BBC8D8D601481331D71AA1880E31.

LogPakFile: Display: "EngageFootprints/Content/Engage/Slides.uasset" offset: 3067851, size: 1878 bytes, sha1: 747D3CC1FDAC4F1D60BA861F4F8B45B5CC6E392B. LogPakFile: Display: "EngageFootprints/Content/Engage/UMG/gfx/ppDrawN.uasset" offset: 3070659, size: 4341 bytes, sha1: 88AAE82599616E67833332ED03B4DF596810AB34. LogPakFile: Display: "EngageFootprints/Content/Engage/UMG/gfx/ppHomeN.uasset" offset: 3075053, size: 4341 bytes, sha1: 335B608360961BA1DAFB8218F574ECB33407C499. ... LogPakFile: Display: "Engine/Content/Slate/Testing/TestRotation.png" offset: 43820412, size: 854 bytes, sha1: 08A997B7E86C69129C91D02F76456E092513F752. LogPakFile: Display: "Engine/Plugins/Blendables/LightPropagationVolume/LightPropagationVolume.uplugin" offset: 48334833, size: 821 bytes, sha1: D7763AC136FC172EA34AD7C9A186954F00714669. LogPakFile: Display: "Engine/Plugins/Developer/UObjectPlugin/UObjectPlugin.uplugin" offset: 48335707, size: 499 bytes, sha1: F7280079FAEBD04A28410E6C8D1CFA091B4E01E7. LogPakFile: Display:

avatar image TestyRabbit May 03 '18 at 03:32 AM

So I have just packaged my files for WindowsNoEditor and it looks very similar to yours and it still says it can't resolve maptest.umap. The Mount point is the same and it has all of the Engine content as well. Where yours gets to EngageFootprints/Content/... is there a map in there too? if so is it a .umap or just a .exp and .ubulk.

avatar image TestyRabbit May 03 '18 at 03:37 AM

When mine stops listing the engine content and starts listing the PakSource content it looks like this:

LogPakFile: Display: "PakSource/AssetRegistry.bin" offset: 35395584, size: 20492 bytes, sha1: E91B38BF6C9AB16C009483CDC4D047F26D832524.
LogPakFile: Display: "PakSource/Config/DefaultEditor.ini" offset: 35416165, size: 0 bytes, sha1: DA39A3EE5E6B4B0D3255BFEF95601890AFD80709.
LogPakFile: Display: "PakSource/Config/DefaultEngine.ini" offset: 35416218, size: 660 bytes, sha1: 8E2BE430B3E3B0B8CBA65AC765633E0905C38E57.
LogPakFile: Display: "PakSource/Config/DefaultGame.ini" offset: 35416951, size: 157 bytes, sha1: E281B3A31E4A4CA85477C59F76D2518DD6581B06.
LogPakFile: Display: "PakSource/Content/maptest.ubulk" offset: 35418112, size: 40996 bytes, sha1: 6E25136D59C1D0CEAE92EEEE4A4868E6428543A7.
LogPakFile: Display: "PakSource/Content/maptest.uexp" offset: 35461120, size: 349218 bytes, sha1: 21C8173C7506E720FEC33D226A2CB91BB820265B.
LogPakFile: Display: "PakSource/CookedIniVersion.txt" offset: 35811328, size: 48484 bytes, sha1: C5805036265936F59A8E2F194F1A6AB06980381E.
LogPakFile: Display: "PakSource/DevelopmentAssetRegistry.bin" offset: 35860480, size: 34407 bytes, sha1: 7C3969BA58B41651CD61EF50FF5DE950057C9283.
LogPakFile: Display: "PakSource/PakSource.uproject" offset: 35894992, size: 79 bytes, sha1: 92413C96F9B1A146AD2B5E86C56EDF80CD9AA62B.

avatar image RichardB May 03 '18 at 03:48 AM

Interesting! Yeah I have a umap in there and no uexp or ubulk files...

LogPakFile: Display: "EngageFootprints/Content/Footprints.umap" offset: 8615285, size: 129508 bytes, sha1: 3FE00EAB5C1C020CE0AE3E9477247C7EEF1AE27C.

avatar image TestyRabbit May 03 '18 at 03:53 AM

Do you know what version of the editor you were using? It looks like .uexp and .ubulk were added sometime around 4.15 to reduce the filesize of .umap so this is probably a non issue but still neat to see lol

avatar image RichardB May 03 '18 at 03:55 AM

yeah I was working in 4.10 - that's cool, good to know :)

avatar image TestyRabbit May 03 '18 at 03:59 AM

Yeah, when I print out the contents of the mounted pakfile it shows this:

LogTemp: Warning: File: /Game/PakSource/Content/maptest.umap
LogTemp: Warning: File: /Game/PakSource/Content/maptest.ubulk
LogTemp: Warning: File: /Game/PakSource/Content/maptest.uexp

so it must build that when it mounts or something, not sure

avatar image RichardB May 03 '18 at 04:19 AM

cool - but it's still showing "/Game/PakSource/Content/" rather than "/Game/Content/" which is worrying me...

avatar image TestyRabbit May 03 '18 at 04:22 AM

Yeah, but unless I go in and change what gets added to the pakfile instead of just building for WindowsNoEditor I'm not sure there is a way around that :/

But even when I did edit the pakfile to only contain the map and material and it was showing as "/Game/Content/" it still couldn't resolve it

avatar image TestyRabbit May 03 '18 at 06:10 AM

@RichardB I don't think this is going to work this way, I might look into utilizing the DLC system to see if I can get something working there. You should send me your paypal so I can at least buy you a beer, you took basically your whole day to help me with this and I really really appreciate it. I'd like to keep the positivity going somehow haha

avatar image RichardB May 03 '18 at 07:14 AM

Ok, it's possible something has changed between 4.10 and 4.17 - I hope you get success with the DLC! Hahaha don't worry about the beer, I brew my own so there's plenty :) I was modelling today anyway so had half my brain free... Once I finish the small contract I'm working on at the moment I'm going to try and get dynamic map and asset loading working from 4.19 - Epic have done more work on the packaging and have even included encryption now...

avatar image TestyRabbit May 03 '18 at 07:18 AM

Fun news is that I've actually gotten it to work! But only if I mount to the /Game/ directory, which doesn't work for me because I can't overwrite all of the content in the game just to mount one map. But it's a step! Just has to do with the routes. If I get it working I'm going to probably write up a tutorial or something similar so there is a resource about this and I'll keep you updated.

avatar image TestyRabbit May 07 '18 at 01:14 PM

Holy shit, 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?

avatar image RichardB May 07 '18 at 07:59 PM

Yeah there's actually quite a few benefits to doing it that way (yes that's the procedure) - you can share assets with a base project and just merge them in meaning much smaller transit files - and compression/decompression will be a lot faster - it also means you're only comp/decomp'ing once...

avatar image theonecalledtom May 07 '18 at 09:12 PM

@RichardB have you used the pak file compression? It works pretty well on my data sets (json files, pngs, jpgs) and means you don't need to add any zip decompress tech across your different platforms.

@TestyRabbit ... you mean you took mounting code out of the code I shared? Any chance you could share your final solution and tell me what you removed to fix what cos I've got to admit I'm not quite following the chronology of this thread!

avatar image RichardB May 07 '18 at 09:53 PM

Yeah I used that first, but I was having to embed the data into multiple BMP files so I could add them to slides in powerpoint files - it was less cpu work to just zip assets one by one and it was windows only. I want to go back to pak files though as yeah I like the transparent compression and now 4.19 has encryption too...

avatar image TestyRabbit May 08 '18 at 07:54 PM

@theonecalledtom I'd be happy to share my final solution with more depth once I fully understand it haha. The only thing I'm having an issue with now is that when I mount a pak that contains a blueprint that's parented to a c++ class, it fails to load saying Missing Dependency, request for CPPParent but it hasn't been created yet. Have you ran into this?

avatar image RichardB May 02 '18 at 09:26 PM

Cool - if it's working in the editor that's a good sign :) 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...

avatar image TestyRabbit May 02 '18 at 09:41 PM

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.

avatar image RichardB May 02 '18 at 10:17 PM

yeah sorry that was a bit of a side track :) 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...

avatar image TestyRabbit May 02 '18 at 10:21 PM

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?

avatar image RichardB May 02 '18 at 10:36 PM

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\"

avatar image TestyRabbit May 02 '18 at 11:00 PM

So the steps I'm using to create a .pak file are the ones i found in this thread (mfish's comment) https://answers.unrealengine.com/questions/258386/loading-map-from-pak-at-runtime.html

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?

avatar image RichardB May 02 '18 at 11:26 PM

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...

avatar image TestyRabbit May 02 '18 at 11:44 PM

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: https://pastebin.com/ZWAPtynK 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.

avatar image TestyRabbit May 03 '18 at 12:08 AM

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

avatar image RichardB May 03 '18 at 12:14 AM

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 :) I'll have a beer to celebrate once it's working :)

avatar image TestyRabbit May 03 '18 at 12:16 AM

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.

avatar image RichardB May 03 '18 at 12:27 AM

I reckon it will be because its in "/Game/PakSource/Content/" - it should be in "/Game/Content/" but I'm not sure on how to tell UnrealPak to go one level up - perhaps by being in that folder when packing?

avatar image TestyRabbit May 03 '18 at 12:48 AM

I tried being in different folders when using UnrealPak.exe but it didn't have any effect on the pakfile contents and their paths :(

Do you remember how you would make pakfiles when you had this working?

avatar image RichardB May 03 '18 at 01:13 AM

haha my memory is pretty bad sorry, fortunately I'd made a batch file which contains:

unrealpak d:\Footprints.pak d:\Footprints.umap d:\Engage*. d:\FootprintMeshes*.

If that's any help... It looks like I put everything in the root of D: to solve it...

avatar image RichardB May 03 '18 at 01:14 AM

looks like the paste lost some of the formatting: unrealpak d:\Footprints.pak d:\Footprints.umap d:\Engage*. d:\FootprintMeshes*.

avatar image RichardB May 03 '18 at 01:16 AM
avatar image TestyRabbit May 03 '18 at 01:27 AM

I tried building my pak using the same method and its giving me this:

 LogTemp: Warning:  D:\PAKS\test3.pak loaded and mounted, listing...
 LogTemp: Warning: File: /Game/maptest.umap
 LogTemp: Warning: File: /Game/test.uasset
 LogPackageName: SearchForPackageOnDisk took   0.167s, but failed to resolve maptest.umap.
 LogPackageName: SearchForPackageOnDisk took   0.166s, but failed to resolve maptest.umap.

Do you know if those are cooked assets or just raw from the content folder of the project?

avatar image RichardB May 03 '18 at 01:36 AM

The only clue I've found so far is that I've named some archives of the dynamic maps as "-WindowsNoEditor" which makes me think I'm using cooked assets built for shipping - I've got some vague recollection that shipping is important...

avatar image TestyRabbit May 03 '18 at 01:48 AM

Yeah I tried with cooked and uncooked assets and got the same thing. gahhhhhhhh this is killing me lol

avatar image TestyRabbit May 03 '18 at 01:51 AM

Did you ever get it to a spot where you could load the map but not the other assets? I have some old code I tried which can load the map but that's the only thing that loads, any materials or custom meshes don't get loaded.

avatar image RichardB May 03 '18 at 01:57 AM

Yeah I think I did have that problem at one point too. When you created the map and asset did you put both in the root of /Game/? Any assets referenced by the map still need to follow their relative path...

avatar image TestyRabbit May 03 '18 at 02:05 AM

Yeah, they are both in D:\UE4\4.17\PakSource\Content

In order to get the map to load, I have to mount the pakfile to FPaths::EngineContentDir() instead of to Game. At which point I get this error after the map loads: LoadErrors: Error: /Engine/maptest : Can't find file for asset. /Game/test. test is the name of my material i applied to some blocks

avatar image RichardB May 03 '18 at 02:25 AM

I think I played with the engine content folder for a while but had success using the game folder - it's possible that the /Game/ folder is not being included in a search order - you may need to add it somewhere, but I'm afraid I can't remember where...

avatar image TestyRabbit May 03 '18 at 02:39 AM

IT could have something to do with the AssetRegistry file?

avatar image RichardB May 03 '18 at 02:54 AM

The AssetRegistry is Editor only so I wouldn't think so. What does the "Pack List" look like now when it logs the contents of the pack?

avatar image TestyRabbit May 03 '18 at 03:02 AM

Which pack list do you mean? In the game when I log it using PakPlatform->IterateDirectoryRecursively() it prints this:

 LogTemp: Warning: File: /Game/maptest.umap
 LogTemp: Warning: File: /Game/test.uasset

And when I list out the pakfile in the command line using UnrealPak.exe D:\PAKS\test.pak -List it prints this:

 LogPakFile: Display: Mount point D:/UE4/4.17/PakSource/Content/
 LogPakFile: Display: "maptest.umap" offset: 0, size: 749458 bytes, sha1: 2F0B6BDD8AFCBFD10B3BEA083D5058B1718229E9.
 LogPakFile: Display: "test.uasset" offset: 749511, size: 99694 bytes, sha1: 3CF6D36A4E575D523AC70A42FB15191389E84011.
 LogPakFile: Display: 2 files (849152 bytes), (849152 filtered bytes).
 LogPakFile: Display: Unreal pak executed in 0.001153 seconds

edit: these text boxes are getting very narrow. I'm going to copy this reply farther up the chain and we can continue there.

WORMHOLE

avatar image theonecalledtom May 03 '18 at 03:59 AM

They narrow down as you approach victory.... well my fingers are crossed for you on this front!

avatar image TestyRabbit May 07 '18 at 01:15 PM

Damn, I have no idea where to do that either...

avatar image theonecalledtom May 03 '18 at 12:20 AM

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.

avatar image TestyRabbit May 03 '18 at 12:25 AM

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.

avatar image TestyRabbit May 07 '18 at 01:15 PM

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("fucker", "/Game/", "D:\\paks\\");


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

(fucker is the name of my map, i apologize for the profanity but it's been a really frustrating week haha :D) [1]: https://answers.unrealengine.com/questions/258386/loading-map-from-pak-at-runtime.html

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hello, when you load the map, the path map should specify how? Which way are you using to load map?

more ▼

answered Jul 26 '16 at 02:51 AM

avatar image

helloliu
1 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hi,

Think of it as an extension to the file system - I load the map after setting a mount point like this:

 FPackageName::RegisterMountPoint("/Game/","path to my map");
 UGameplayStatics::OpenLevel(World,"LevelName");

The "path to my map" is the physical path on disk to the map file (excluding the map name) - it can be embedded in a pak file or just be a umap file on disk. The "/Game/" is the root path you want to map it to - "/Game/" is just where I have things, you can place them in other folders within that.

more ▼

answered Jul 26 '16 at 03:52 AM

avatar image

RichardB
134 3 4 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Do you mean the assets within the pak file - are you trying to load those? If so, the path to them should be relative to the mount point you set. If you used "/Game/" which is the root you would specify "Meshes/MyMesh.uasset" for a mesh that is located in a "Meshes" folder.

more ▼

answered Jul 27 '16 at 07:16 AM

avatar image

RichardB
134 3 4 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I loaded map from pak file, it can be loaded into the map, but the map of uasset gone, how to load the map with uasset? Thanks.

more ▼

answered Jul 27 '16 at 07:01 AM

avatar image

helloliu
1 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question