Crashing when using ConstructorHelpers

I am trying to change my character’s chest mesh during run time using the ConstructorHelper::FObjectFinder but, the Editor crashes whenever I make the call.

Line causing the crash:

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

Thank you in advance.

Although I’m not sure, I think the ConstructorHelpers can only be called int the constructor function, at the top of your cpp files, it should look like this :

AYourClass::AYourClass(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)

If you want to change your mesh at runtime (I m just guessing here), maybe you should store a reference for your different mesh in the character, and spawn them with SpawnActor when you need to change?

That was my fear. Unfortunately I want to store the mesh names in a database and switch to the mesh when the armor piece (Chest/Legs/Head/Etc) is equipped. Does anyone know how I can accomplish dynamic mesh changing during run time?

Try this.


I’d suggest avoiding raw string references if at all possible; they don’t work with the cooker and are extremely fragile due to renames/typos/etc… Have a look thru this documentation: Asynchronous Asset Loading | Unreal Engine Documentation and see if you can make use of TAssetPtr instead.

Michael Noland