Search code examples
unreal-engine4

Loading assets with FObjectFinder


I am working FPS example code included in the engine. I am trying to load a new skeletal mesh that I added in to the content browser and assign to the my SkeletalMesh Component based on certain conditions.

This is the code I am trying to use for loading the Skeletal Mesh, but seemingly it cannot load from this path, as it is unable to fine the asset:

 ConstructorHelpers::FObjectFinder<USkeletalMesh> newAsset(TEXT("SkeletalMesh'/Content/FirstPerson/FPWeapon/Mesh/SK_FPGun.uasset'"));

Is there anything wrong in the way the path is given? It is just a simple load of an asset

Thanks in advance


Solution

  • You have your path wrong. It should be "SkeletalMesh'/Game/FirstPerson/FPWeapon/Mesh/SK_FPGun.uasset'". (Assuming that you have folder named FirstPerson in a Content folder).

    The safest way to get asset's reference is by Right mouse click on asset and then click on Copy reference. This way you can always get correct path to use in FObjectFinder.