How can I create a USkeletalMesh from reference name?

I am trying to change the chest mesh of my modular pawn during run time. I have the reference to the Skeletal Mesh but, I cannot for the life of instantiate a USkeletalMesh.

USkeletalMesh newMesh = SkeletalMesh'/Game/SkeletalMeshDir/Chest_Mesh.Chest_Mesh';

I have managed to change the mesh using a blueprint set skeletal mesh but, I’d prefer to do this programmatically.

There’s a few help methods in the aptly named ConstructorHelpers class.

static ConstructorHelpers::FObjectFinder<USkeletalMesh> mesh(TEXT("SkeletalMesh'/Game/Character/HeroTPP.HeroTPP'"));

Thank you very much!

Though, I have another problem now. When this constructor runs it crashes my UEditor. I know this is a bit off the original question but, have any ideas to prevent the crashing?

I wish it were that easy. I am copying the reference from the editor and pasting it in the double quotes of this constructor.

static ConstructorHelpers::FObjectFinder<USkeletalMesh> currentMesh(TEXT("SkeletalMesh'/Game/CC_Sentinal_Armor/Models/Sentinal_Chest_Greek.Sentinal_Chest_Greek'"));

If anyone can notice any syntax errors here, let me know. The answer is otherwise correct though, I’ll go ahead and mark it.

I’m afraid I have no idea but what seems the most likely is maybe you got the reference string wrong?

Hello, @Hagg. If you are still having problems with running the constructor, please post a new question. It will be easily visible to more people that way and someone may have an answer for you.

Have a great day.