How to set the hair mesh to follow the animation? I am trying this.

Hair = CreateDefaultSubobject<USkeletalMeshComponent>("Hair");
    Hair->AttachToComponent(MyCharacter::GetMesh(), FAttachmentTransformRules::KeepWorldTransform, TEXT("head"));

UPROPERTY(EditAnywhere, Category = "Components")
    class USkeletalMeshComponent* Hair;


I have attached the hair mesh to the Head socket but the hair mesh is not following the animation. The hair mesh is called Hair_Mesh and has been attached in the editor while the Hair skeletal mesh component is already sets to UPROPERTY(EditAnywhere, Category = "Components")


By the looks of it, the hair is attaching to the mesh but isn't animating.

You can set the Hair component to use the animation of the mesh by calling it's Master Pose Component.


You put this in your cpp constructor under where you've attached it to the mesh.

  • \$\begingroup\$ Not working for me ( \$\endgroup\$
    – josil
    May 21 at 13:15
  • \$\begingroup\$ What happens if you remove or comment out the line beginning Hair->AttachToComponent ? \$\endgroup\$
    – Stephen
    May 21 at 15:37
  • \$\begingroup\$ After commenting this line the Hairs mesh is not following the head and animations in the lobby, and when un-commenting the line, the hairs mesh is following the head only in the lobby but in the editor not following. \$\endgroup\$
    – josil
    May 21 at 16:11
UPROPERTY(BlueprintReadWrite, NonTransactional, meta = (Category = "Default", OverrideNativeName = "Hair"))
        USkeletalMeshComponent* Hair;
    UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, meta = (DisplayName = "Skin Met R", Category = "SkeletalMesh", MultiLine = "true", OverrideNativeName = "SkinMetR"))
        UMaterialInstanceDynamic* SkinMetR;
    AMyCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
    virtual void PostLoadSubobjects(FObjectInstancingGraph* OuterInstanceGraph) override;
    static void CustomDynamicClassInitialization(UDynamicClass* InDynamicClass);
    static void StaticDependenciesAssets(TArray<FBlueprintDependencyData>& AssetsToLoad);
    static void StaticDependencies_DirectlyUsedAssets(TArray<FBlueprintDependencyData>& AssetsToLoad);
virtual void UserConstructionScript();
    UFUNCTION(BlueprintCallable, meta = (Category = "SkeletalMesh", OverrideNativeName = "InitSkeletalMesh"))
        virtual void InitSkeletalMesh()

void AMyCharacter::InitSkeletalMesh(){
bool CallFunc_K2_AttachToComponent_ReturnValue{};
        CallFunc_K2_AttachToComponent_ReturnValue = Hair->USceneComponent::K2_AttachToComponent((*(AccessPrivateProperty<USkeletalMeshComponent* >((this), ACharacter::Mesh() ))), FName(TEXT("head")), EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, true);
  • \$\begingroup\$ Not working for me ( \$\endgroup\$
    – josil
    May 21 at 13:15
  • 1
    \$\begingroup\$ Welcome to GDSE & thankyou for contributing. This answer could be improved by include an explanation of how it solves the problem & why you included these particular steps. \$\endgroup\$
    – Pikalek
    May 23 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.