Meshes in packaged game: "Couldn't find file for package .... requested by async loading code."

I have custom StaticMesh Assets in a sub directory of my project. These Assets can be selected by players at runtime. On BeginPlay in the PlayerController, I use the AssetRegistry to discover all CachedPaths of Assets, then filter according to the directory in which the Assets are stored, generating categories from the names of the sub directories.

In the editor, this works perfectly fine: the categories are generated correctly, all Assets are loaded and I can place Actors with these StaticMeshes as Components in the level. However, in the packaged game running on a dedicated server, I receive the error above. This only occurred after I started categorizing the Meshes in different sub directories.

However, I added the directories containing the StaticMesh Assets and the directories where the associated Materials are located to the “Additional Asset Directories to Cook” in the Packaging settings of the project. What could be the problem? Packaging the project does not cause any problems.

When packaging a game, the assets are cooked and compressed, so they are not stored in the same directory structure as they are in the editor. This means that the AssetRegistry may not be able to find the custom StaticMesh assets in the subdirectory that you’ve specified.

To resolve this issue, you will most likely need to modify the way that the custom StaticMesh assets are being accessed at runtime. Instead of using the AssetRegistry to discover the assets at runtime, you should use a hard-coded path to the assets. This way, you can ensure that the assets are being loaded from the correct location, regardless of whether the game is running in the editor or as a packaged build.

Another thing to check is that all the assets are being cooked properly , you should check the log files after packaging the game. These logs will tell you which assets were successfully cooked and which ones were not.

Based on the Editor s Output Log, cooking and packaging terminates without errors, therefore I assume this is not the problem.

I only started using the AssetRegistry because back then, I thought this was the way to go given the fact that I did not know how Assets would be organized in the packaged game. I will look into specifying hard coded paths, thank you for your input!

Do you happen to have any resource on that topic?

In your project folder head over to Saved/Cooked/WindowsNoEditor/YourProject/Content to check your assets are really being included in cooked build.

Alternatively you could use UnrealPak.exe -List to check what’s inside the pak file.

If stuff started failing only after making sub directories, make sure you enabled recursive search when doing asset registry lookups.

Ticking the “Recursive Search” box in the Blueprint node “Get Assets by Path” with the Asset registry as target did not do the trick.

Checking the WindowsClient folder, which I assume is the equivalent to the WindowsNoEditor folder for the Client build target, reveals that the assets are indeed cooked and the structure of the directory the Meshes are stored in actually is the very same as in the regular content folder.

However, I cannot find any Meshes in the .pak file using UnrealPak.exe. However, the names of the assets are still being correctly displayed in the game - but no Meshes are being displayed.