# How to load level from pak files?

**URL:** <https://forums.unrealengine.com/t/how-to-load-level-from-pak-files/2016082>\
**Category:** Programming & Scripting\
**Tags:** pak, unreal-engine, question\
**Created:** [September 11, 2024, 12:07pm UTC](https://forums.unrealengine.com/t/how-to-load-level-from-pak-files/2016082 "2024-09-11T12:07:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramedons](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ramedons](https://forums.unrealengine.com/u/Ramedons)\
**Post date:** [September 11, 2024, 12:07pm UTC](https://forums.unrealengine.com/t/how-to-load-level-from-pak-files/2016082/1 "2024-09-11T12:07:33Z")

</div>

Hi, I am working on loading levels from pak files. I successfully loaded widget assets, but I failed to load the level using a similar method. I placed them in the same directory, but I encountered issues：

```auto
LogLinker: Warning: Failed to load '/Game/Pak2/NewWorld': Can't find file. 

```

Here is my code:

```auto
    TSharedPtr<FPakPlatformFile> pakPlatformFile = MakeShareable(new FPakPlatformFile());
    pakPlatformFile->Initialize(&FPlatformFileManager::Get().GetPlatformFile(), TEXT(""));
    IPlatformFile& oldPlatformFile = FPlatformFileManager::Get().GetPlatformFile();
    FPlatformFileManager::Get().SetPlatformFile(*pakPlatformFile);

    if (WITH_EDITOR)
    {
        pakPlatformFile->Mount(TEXT("D:/code_study/Content/Paks/pakchunk2-Windows.pak"), 1, TEXT("D:/code_study/Content/Pak2/"));
        GAllowUnversionedContentInEditor = true;
    }

    else
    {
        pakPlatformFile->Mount(TEXT("D:/code_study/Content/Paks/pakchunk2-Windows.pak"), 1, TEXT("../../../Content/Pak2/"));
        FPlatformFileManager::Get().InitializeNewAsyncIO();
    }

    FString worldPath = TEXT("/Game/Pak2/NewWorld");
    UGameplayStatics::OpenLevel(GetWorld(), FName(*worldPath));
    FPlatformFileManager::Get().SetPlatformFile(oldPlatformFile);

```

BTW I am using UE 5.3. I wonder if there is any tutorial introducing how to load maps from pak files?

---

<div class="post-metadata">

**Author:** ![Ramedons](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ramedons](https://forums.unrealengine.com/u/Ramedons)\
**Post date:** [September 11, 2024, 12:56pm UTC](https://forums.unrealengine.com/t/how-to-load-level-from-pak-files/2016082/2 "2024-09-11T12:56:13Z")

</div>

Ah, the problem is solved. I should firstly load the world and then open the level.

```auto
    FString worldPath = TEXT("World'/Game/Pak2/NewWorld.NewWorld'");
    UWorld* LoadedWorld = LoadObject<UWorld>(nullptr, *worldPath);
    if (LoadedWorld)
    {
        FString LevelName = LoadedWorld->GetName();
        UGameplayStatics::OpenLevel(GetWorld(), FName(*LevelName));
    }
    else
    {
        UE_LOG(LogTemp, Error, TEXT("Failed to load world."));
    }

```
