Hi,
In our game, we have different uniforms per character and we can add any type of shoes to the character. To make sure that they are synchronized visually, we merge the 2 skins (shoes and body) together at runtime using USkeletalMergingLibrary. The cloth simulation works great without the merge but if I tried to merge the shoes with the rest of the body, then the cloth simulation stops working (it looks like before without cloth). I have added the same cloth asset in the shoes but it didn’t make a difference. Is it possible to merge 2 skeletal meshes with cloth? If yes, then what am I doing wrong (see the code below)? Thanks.
Laurent
`void CopyClothFromMesh(USkeletalMesh* sourceMesh, USkeletalMesh* targetMesh)
{
if (!IsValid(sourceMesh) || !IsValid(targetMesh))
return;
// Iterate over clothing assets in the source mesh.
for (UClothingAssetBase* clothingAsset : sourceMesh->GetMeshClothingAssets())
{
if (!IsValid(clothingAsset))
continue;
// Duplicate the clothing asset.
UClothingAssetBase* duplicatedAsset = DuplicateObject(clothingAsset, targetMesh);
if (IsValid(duplicatedAsset))
{
// Add to target mesh
targetMesh->AddClothingAsset(duplicatedAsset);
}
}
}
// Do the merge of shoes and body.
FSkeletalMeshMergeParams mergeParams;
mergeParams.MeshesToMerge.Add(characterMesh);
mergeParams.MeshesToMerge.Add(MotionGroupAsset->Shoes);
mergeParams.Skeleton = characterMesh->GetSkeleton();
mergeParams.StripTopLODS = 0;
mergeParams.bNeedsCpuAccess = true;
mergeParams.bSkeletonBefore = true;
USkeletalMesh* mergedMesh = USkeletalMergingLibrary::MergeMeshes(mergeParams);
UPhysicsAsset* physicsAsset = characterMesh->GetPhysicsAsset();
mergedMesh->SetPhysicsAsset(physicsAsset);
// Copy the clothes.
CopyClothFromMesh(characterMesh, mergedMesh);
// Set the final mesh.
MeshComponent->SetSkeletalMesh( mergedMesh );
MeshComponent->bDisableClothSimulation = false;
MeshComponent->ClothTickFunction.bCanEverTick = true;`