Issue with CopyMeshFromStaticMesh Function in Packaged Game

Hello,

I am currently experiencing an issue with the CopyMeshFromStaticMesh function from the UGeometryScriptLibrary_StaticMeshFunctions class in a packaged Unreal Engine game. While the function operates as expected within the UE Editor, it fails when called in the packaged game environment.

Description of the Problem:

  • Environment: The issue arises in the packaged version of the game; however, everything works correctly in the Unreal Editor.
  • Function Behavior: When invoking CopyMeshFromStaticMesh, it returns a Failure outcome for certain static mesh assets, despite those assets being properly loaded and visible in the game play. Interestingly, this issue is inconsistent, as the function succeeds for some meshes but fails for others under similar conditions.
  • Failure Condition: According to the function’s implementation, a Failure outcome is primarily returned if either the source static mesh (FromStaticMeshAsset) or the target dynamic mesh (ToDynamicMesh) is nullptr. However, all involved assets appear to be correctly referenced and loaded, as evidenced by their visibility in gameplay.
  • Specific Observation: The problem seems to be selective, affecting only certain static meshes. This has led to considerable confusion since the meshes that fail do not exhibit any obvious differences from those that succeed in terms of asset settings or properties.

Steps Taken:

  • I have verified the presence and loading of all static meshes in the packaged game, ensuring that they are not nullptr.
  • I’ve reviewed the packaging settings to confirm that all necessary assets are included in the build.
  • Debugging efforts have been focused on understanding the difference in asset handling between the editor and the packaged game environment, but no clear cause has been identified yet.

I am reaching out to the community for insights into what might be causing this selective failure of the CopyMeshFromStaticMesh function in a packaged game. Any advice on additional debugging steps or known issues with asset packaging that could lead to this behavior would be greatly appreciated.

Thank you in advance for your assistance.

1 Like

Looks like the function takes a different path depending on if its running in the editor or not.
Maybe try testing with RequestedLOD.LODType == EGeometryScriptLODType::RenderData.

1 Like

The root cause was that the bAllowCPUAccess property of the StaticMesh was not set to true. This property is essential for runtime access to the mesh data, which I overlooked.

The solution was straightforward once the issue was identified. I navigated to the problematic StaticMesh assets in the Unreal Editor and ensured that their bAllowCPUAccess flag was set to true under the mesh properties. This change allowed the CopyMeshFromStaticMesh function to execute successfully in the packaged game.

2 Likes

Thanks for your reply! I appreciate your help.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.