How to load a map from a dynamic level

yeah I was working in 4.10 - that’s cool, good to know :slight_smile:

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

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

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

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

cool - but it’s still showing “/Game/PakSource/Content/” rather than “/Game/Content/” which is worrying me…

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 :confused:

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

Yeah - using something like FFileHelper::LoadFileToArray.

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)

@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

@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 :confused:

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

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

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 :slight_smile: 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…

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?

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.

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?

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.

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

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.

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 :slight_smile: