In my main zombie character (made in C++) I want to attach the Animation Blueprint to the Mesh. I have done it successfully with the following code:
UClass* AnimInstanceClass = FindObject<UClass>(ClassPackage, TEXT("/Game/Meshes/SkeletalMeshes/Zombie/zombie_AnimBlueprint.Zombie_AnimBlueprint_C"));
if (AnimInstanceClass) {
MeshComponent->SetAnimInstanceClass(AnimInstanceClass);
}
The code works perfectly, but when I restart the editor, the animation blueprint is not attached. I have to open the Animation Blueprint, and then, without changing nothing, it works. If I build the game without opening the blueprint the same happens. This is not just for Animation Blueprints, but for all blueprint classes. Thanks in advance.