Download

Modding tutorial on 4.12 - 4.14 + not possible? (Pak file not loading auto at launch)

Hello,

I followed this tutorial on 4.9 -> A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums

and worked very well, now I’m trying to do the same with my current project in 4.12.5 and I can’t load the map contained in the pak file.

No errors, everything packages and compile fine, it’s just like the pak file is not automaticlly loaded like it’s stated in the tutorial. I also tried to replicate the tutorial in 14.3 an 15.0 p3, and ran in a handful more problems, always leading to the final result of not being able to load the pak. But it works fine in 4.9!

I also tried to use the Onmountpak.execute to load the pak files manually, also tried with absolute URLs,also at the game root or content root, nothing worked so far.

Any ideas, even the smallest information would be overwhelmingly appreciated!

Thanks for reading!!

PS: Also tried with blank template projects, and migrated version of the tutorial one in all the engine versions stated above.

Slowly making progress, managed to load the pak file at runtime and log all the pak files content, now my problem is that my Mod.pak does not contain the map.

Take a look at these links if you encounter the same problem (Very Helpful Thanks Pierdeck!!!)

https://answers.unrealengine.com/questions/361765/fpakplatformfile-make-public.html

Here’s my current very ugly and not clean code if you wondered (I’m talking to you person on the internet searching for UE4 pak loading documentation), Don’t use it as is, it logs everything, on screen and in the logs too.

Need to make FPakListEntry Struct public before running this, thus require to build the engine


// Load Pak
void AFireStarterGameMode::LoadPakFile(FString Path)
{
	if (FCoreDelegates::OnMountPak.IsBound()) {
		FCoreDelegates::OnMountPak.Execute(Path, 3, nullptr); //Number should be 0-4; specifies search order
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Pak should be loaded"));
	}
	else
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Is not Bound"));
	}

	IPlatformFile& InnerPlatformFile = FPlatformFileManager::Get().GetPlatformFile();

	FPakPlatformFile* PakPlatformFile = new FPakPlatformFile();
	PakPlatformFile->Initialize(&InnerPlatformFile, TEXT(""));

	//PakPlatformFile->Mount(*PakToLoad, 0, *(Path)); // Not Original

	TArray<FPakPlatformFile::FPakListEntry> MountedPaks;
	PakPlatformFile->GetMountedPaks(MountedPaks);

	UE_LOG(LogTemp, Warning, TEXT("Befroe Scan Loop"));
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Before Scan Loop"));
	//ignore first pak, because it is default game pak and we don't need iterate over it
	for (int32 i = 0; i < MountedPaks.Num(); i++)
	{
		UE_LOG(LogTemp, Warning, TEXT("OnePack"));
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("OnePack"));
		const FPakPlatformFile::FPakListEntry& mountedPak = MountedPaks*;
		const TMap<FString, FPakDirectory>& pakDirectoryMap = mountedPak.PakFile->GetIndex();

		for (TMap<FString, FPakDirectory>::TConstIterator It(pakDirectoryMap); It; ++It)
		{
			FString Key = It.Key();
			const FPakDirectory& Val = It.Value();

			for (FPakDirectory::TConstIterator It2(Val); It2; ++It2)
			{
				FString Key2 = It2.Key();
				FPakEntry* pakEntry = It2.Value();

				//if (Key2.Contains(TEXT(".umap")))
				//{
					UE_LOG(LogTemp, Warning, TEXT("OneFile"));
					GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("OneFile"));
					//this is where you will get map name of course if your map have *.umap extension:)
					Key2 = Key2;
					UE_LOG(LogTemp, Warning, TEXT("File: %s"),*Key2);
					GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red,TEXT("File: " + Key2));
				//}
			}
		}
	}
}

Long story short packing assets directly with unrealpak.exe worked :wink:

you can see now UE4 forum is how helpful :smiley: