Hello all!
I am having a problem using the skeletal mesh merge illustrated here Working with Modular Characters | Unreal Engine Documentation with complex collision. The Merge mesh code is the same as the one in the page, called from a class that extends ACharacter.
Then my collision on the actor supposed to trace is set up as follows:
FCollisionQueryParams QueryParams;
QueryParams.AddIgnoredActor(this);
QueryParams.bReturnPhysicalMaterial = true;
QueryParams.bTraceComplex = true;
const bool Result = GetWorld()->LineTraceSingleByChannel(HitResult, EyesPosition, TraceEnd, ECC_GameTraceChannel2, QueryParams);
This is the function that builds the character mesh (I left an option to disable the modular character and use the default mesh):
void ASOComposableCharacter::RebuildCharacterMesh()
{
if (this->bIsComposabeCharacter)
{
ECollisionEnabled::Type CurrentCollisionEnabled = GetMesh()->GetCollisionEnabled();
ECollisionResponse CurrentCollisionResponse = GetMesh()->GetCollisionResponseToChannel(ECC_GameTraceChannel2);
for (auto& Elem : ComposableParts) {
if (Elem.Value.CurrentPart)
{
Elem.Value.CurrentPart->bEnablePerPolyCollision = true;
SkeletalMeshMergeParams.MeshesToMerge.Add(Elem.Value.CurrentPart);
} else
{
// Apply default part
Elem.Value.DefaultPart->bEnablePerPolyCollision = true;
SkeletalMeshMergeParams.MeshesToMerge.Add(Elem.Value.DefaultPart);
}
}
USkeletalMesh* ComposedMesh = USOMeshMergeFunctionLibrary::MergeMeshes(SkeletalMeshMergeParams);
GetMesh()->SetSkeletalMesh(ComposedMesh);
GetMesh()->SetCollisionEnabled(CurrentCollisionEnabled);
GetMesh()->SetCollisionResponseToChannel(ECC_GameTraceChannel2, CurrentCollisionResponse);
}
}
The issue is that when bIsComposableCharacter is false (so when it uses the default mesh) everything works. When I enable it, apparently the collision trace does not intercept the mesh.
Form a further test, it seems that the whole new mesh does not collide with anything, despite my call to SetCollisionEnabled. Reducing the capsule radius to a small number, my other character is able to walk through the mesh.
Any hint?
Thanks!
Stefano