Skeletal mesh set in C++ class does not get set in unreal editor

UE 4.15.3

I have noticed an interesting bit of behaviour, when setting the USkeletalMesh of an ACharacter object the skeletal mesh that gets set does not reproduce itself in the blueprint class that inherits from it in the Unreal Editor but does still take effect in the code, if you have cleared the skeletal mesh in the blueprint first and compiled the blueprint. Going into the blueprint and selecting the Mesh component shows no skeletal mesh has been set even if you close the editor and reopen it, my understanding is the blueprint should read the C++ code and reset the skeletal mesh.

Recreation steps:

  1. Make new C++ project .

  2. Add animation starter pack asset collection available from marketplace.

  3. Create new C++ class of Type ACharacter.

  4. Add the following code to your character class’s constructor in the cpp file:

    static ConstructorHelpers::FObjectFinder NewMesh(TEXT(“SkeletalMesh’/Game/AnimStarterPack/UE4_Mannequin/Mesh/SK_Mannequin.SK_Mannequin’”));
    GetMesh()->SetSkeletalMesh(NewMesh.Object);

  5. Close Unreal Editor.

  6. Compile code.

  7. Open Unreal Editor.

  8. Make new folder in Unreal Editor Content Browser at root called “assets”.

  9. In Content Browser go to the C++ Classes section and create a blueprint which inherits from your new character class.

  10. Go into the new blueprint and you should see your skeletal mesh has been set. Clear the mesh, recompile the blueprint and save.

  11. Close unreal editor.

  12. reopen unreal editor and go back to the blueprint. The skeletal mesh is still unset and will never reset.

The fix for this is to reset the mesh in the blueprint using the unreal editor, then your code starts affecting what skeletal mesh the blueprint uses.

I remember some weird behaviour of c++ construction script for blueprint children, it was the late night so I’m not even sure, but is your bp calls parent construction script on construction script?

Also, it’s not that good of a practice to have such a reference to asset inside a code, maybe you should just set it up in bp class as recommended by epic.

Hello Kytie,

I believe this is working as intended. While the asset is not automatically reset to the value that is declared in the Constructor, you can always manually do so without needing to actually search for the asset. The Reset to Default button (the little yellow arrow) beside the field will return the field to the value that is set in the Constructor. This allows for Blueprints that inherits from classes with many values set in the Constructor to be more versatile, as you may not actually want it to reset all of the values automatically whenever the Blueprint is loaded.