I am working on a realtime fracture system using Dynamic mesh and UE fracturing: I’ve created an Actor (i.e. DestructibleMesh) with a root component set to DestructibleMeshComponent (a component which extends DynamicMeshComponent).
To enable collision on this actor, as other posts suggest ([1],[2]), I’ve used ComplexAsSimple as Collision type.
Here the DestructibleMesh constructor:
ADestructibleMesh::ADestructibleMesh(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
// TODO: needed?
SetActorEnableCollision(true);
DestructibleMeshComponent = CreateDefaultSubobject<UDestructibleMeshComponent>(TEXT("DestructibleMeshComponent"));
DestructibleMeshComponent->SetMobility(EComponentMobility::Movable);
DestructibleMeshComponent->SetGenerateOverlapEvents(false);
// TODO: cannot simulate if using ComplexAsSimple
DestructibleMeshComponent->SetSimulatePhysics(true);
DestructibleMeshComponent->SetEnableGravity(true);
DestructibleMeshComponent->bEnableComplexCollision = true;
DestructibleMeshComponent->CollisionType = ECollisionTraceFlag::CTF_UseComplexAsSimple;
DestructibleMeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
DestructibleMeshComponent->OnComponentHit.AddDynamic(this, &ADestructibleMesh::OnComponentHit);
SetRootComponent(DestructibleMeshComponent);
}
In this way, the collision works but I cannot simulate physics on this actor:
Note that if you are using UseComplexAsSimple you cannot simulate the object
In fact a warning in the log says:
Trying to simulate physics on ‘DestructibleMeshComponent’’ but it has ComplexAsSimple collision.
Are there any workarounds that let me enable both collision and physics simulation on a dynamic mesh?