Hello, I set up a system so that the player’s mesh and skeleton can change, but I have different animation blueprints for each skeleton. So, I would like to change the animation blueprint when the skeleton is changed, but I don’t know how to do this. Can someone help ?
You have to use following code to change animation blueprint. This function also changes animation mode to the BlueprintAnimated
SkeletalMeshComponent->SetAnimInstanceClass(AnimBlueprint->GeneratedClass);
Full code to change both skeleton and anim BP (taken from the actor factory)
// Term Component
NewSMActor->GetSkeletalMeshComponent()->UnregisterComponent();
// Change properties
NewSMActor->GetSkeletalMeshComponent()->SkeletalMesh = SkeletalMesh;
if (NewSMActor->GetWorld()->IsGameWorld())
{
NewSMActor->ReplicatedMesh = SkeletalMesh;
}
// Init Component
NewSMActor->GetSkeletalMeshComponent()->RegisterComponent();
if( AnimBlueprint )
{
NewSMActor->GetSkeletalMeshComponent()->SetAnimInstanceClass(AnimBlueprint->GeneratedClass);
}
Ok, thank you, I will try it.