Hey everyone,
I’m working on a collaborative viewer app in UE 5.3 and I’ve run into an issue with loading levels from PAK files. Let me explain my setup and what’s going wrong.
I have two separate projects. The main one contains all the game logic - the GameModes, GameInstance, PlayerControllers, UI, everything code-related. When I package this, it creates the executable that the user runs.
Then I have a second project that’s purely for content - just maps, meshes, textures, materials, etc. I package this into separate PAK files that get loaded dynamically at runtime. The idea is to keep the game logic separate from the world content.
Here’s the problem: when I mount one of these content PAKs and try to open the level, it can’t find the GameMode even though it’s in my base project. The logs show:
LogStreaming: Error: Couldn't find file for package /Game/CollaborativeViewer/Blueprints/GameMode/BP_CollaborativeViewer_GameMode
LogLoad: Game class is 'GameModeBase'
So it just falls back to the default GameModeBase instead of using my custom one.
I’ve tried a few things already. First, I configured GameModeMapPrefixes in DefaultEngine.ini like this:
[/Script/EngineSettings.GameMapsSettings]
+GameModeMapPrefixes=(Prefix="MainMap",GameMode="/Game/CollaborativeViewer/Blueprints/GameMode/BP_CollaborativeViewer_GameMode.BP_CollaborativeViewer_GameMode_C")
I also tried passing the ?game= parameter in the OpenLevel call but it doesn’t work either. I even added a 2-second delay to make sure the Asset Registry finishes scanning. But it still doesn’t find the GameMode.
My best guess is that when OpenLevel does its async loading for a level from the content PAK, it only searches within that specific PAK and doesn’t look in my base project where the GameMode actually is.
So my question is: is there a proper way to make this work? Can the level loader find a GameMode that’s in the base executable when opening a level from a dynamically mounted PAK?
I really want to avoid putting the GameMode in every content PAK because that defeats the whole point of keeping game logic separate from content.
Any advice would be super helpful. Thanks!
Engine Version: UE 5.3.2
Platform: Windows
Build Config: Development