Download

Set Animation Blueprint to Character from C++

I am trying to set an animation blueprint class to a character from C++. How can I do it and what is the best way to do it?
Thank in advance :cool:

you can set new AnimBp of a skeletal mesh component, not the character, so add this code to your skeletal mesh component class, or add GetMesh()-> before the function calls:

// as I remember this is needed to get it work
SetAnimationMode(EAnimationMode::AnimationBlueprint);

// I store the AnimBp classes is an array of UAnimInstance-s for each weapon, so select the new class to use
TSubclassOf<UAnimInstance> AnimBp = AnimationBlueprintClasses[WeaponUsed];

// switch to the new AnimBp
if (AnimBp)
{
SetAnimInstanceClass(AnimBp);
}