Looks like animation is broken. This is basically the example plus the 2 lines copying the animation from the original mesh. The skeletal mesh works fine is it's just static without the animation.
The video attached is using the skeletalmesh and animation from the content examples. I've tried with other skeletal meshes and same issue.
This is tested with 4.27.2
void ADuplicateSkeletalMesh::Duplicate()
{
TArray<FMeshSurface> OutSurfaces;
TArray<int32> OutSurfacesVertexOffsets;
TArray<int32> OutSurfacesIndexOffsets;
TArray<UMaterialInterface*> OutSurfacesMaterial;
USkeletalMeshComponent* SkeletalMeshComp = SkeletalMeshActor->GetSkeletalMeshComponent();
FRuntimeSkeletalMeshGenerator::DecomposeSkeletalMesh(
SkeletalMeshComp->SkeletalMesh,
OutSurfaces,
OutSurfacesVertexOffsets,
OutSurfacesIndexOffsets,
OutSurfacesMaterial);
USkeletalMeshComponent* comp = FRuntimeSkeletalMeshGenerator::GenerateSkeletalMeshComponent(
this,
SkeletalMeshComp->SkeletalMesh->Skeleton,
OutSurfaces,
OutSurfacesMaterial);
comp->AnimationData = SkeletalMeshComp->AnimationData;
comp->SetAnimationMode(EAnimationMode::AnimationSingleNode);
}
Skeletalmesh on the left is the original and the right is the duplicated one.
https://user-images.githubusercontent.com/70504591/173758191-6dccc622-046f-4ea2-8370-65561c03f5e5.mp4