Loading UDestructibleMesh asset from filesystem

Using the tutorial: Components and Collision as a guide, to dynamically load a SphereShape the following is done:

AClass::AClass()
{
    // Create USphereComponent
    USphereComponent *sphere = NULL;
    sphere = CreateDefaultSubobject<USphereComponent>(TEXT("Root"));
    sphere->InitSphereRadius(1.0f);
    sphere->SetCollisionProfileName(TEXT("PhysicsActor"));
    sphere->SetSimulatePhysics(true);
    sphere->WakeRigidBody();

    // Create UStaticMeshComponent
    UStaticMeshComponent *mesh = NULL;
    mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
    mesh->SetupAttachment(RootComponent);

    // Load asset from filesystem
#define ASSET TEXT("/Game/MobileStarterContent/Shapes/Shape_Sphere.Shape_Sphere")
    static ConstructorHelpers::FObjectFinder<UStaticMesh> asset(ASSET);
#undef ASSET
    if (asset.Succeeded())
        mesh->SetStaticMesh(asset.Object);

    RootComponent = sphere;
}

Now, when I try the same set of steps, but this time for an Actor that has a UDestructibleComponent instead of a USphereComponent:

AClass::AClass()
{
    // Create our UDestructibleComponent
    UDestructibleComponent *destructible = NULL;
    destructible = CreateDefaultSubobject<UDestructibleComponent>(TEXT("Root"));
    destructible->SetCollisionEnabled(ECollisionEnabled::PhysicsOnly);
    destructible->SetSimulatePhysics(true);
    destructible->SetEnableGravity(false);
    destructible->WakeRigidBody(NAME_None);

    // Load asset from filesystem
#define ASSET TEXT("/Game/MobileStarterContent/Shapes/Shape_Cube_DM")
    static ConstructorHelpers::FObjectFinder<UDestructibleMesh> asset(ASSET);
#undef ASSET
    if (asset.Succeeded())
        UE_LOG(LogTemp, Warning, TEXT("It worked!"));

    RootComponent = destructible;
}

I receive the following errors:

ConstructorHelpers.h:105:20: error: cannot initialize a parameter of type 'UObject *' with an lvalue of type 'UDestructibleMesh *'
ValidateObject( Object, PathName, ObjectToFind );
                ^~~~~~
                
ConstructorHelpers.h:29:19: error: incomplete type 'UDestructibleMesh' named in nested name specifier
UClass* Class = T::StaticClass();
                ^~~

What is the correct way to load a DestructibleMesh from the filesystem and apply it to the UDestructibleComponent?

Thanks in advance for any help!

Update 1

I’ve tried adding .Shape_Cube_DM to the end of the string, similar to how the first asset was imported, but no luck.

Thread bump.

Figured it out - the assets needs to be loaded as a USkeletalMesh, and then casted to a UDestructibleMesh whenever that type is needed.

// Sets default values
ADestructibleBox::ADestructibleBox()
{
    PrimaryActorTick.bCanEverTick = true;

    // Create our UDestructibleComponent
    UDestructibleComponent *destructible = NULL;
    destructible = CreateDefaultSubobject<UDestructibleComponent>(TEXT("Destructible"));
    destructible->SetCollisionEnabled(ECollisionEnabled::PhysicsOnly);
    destructible->SetSimulatePhysics(true);
    destructible->SetEnableGravity(false);
    destructible->WakeRigidBody(NAME_None);

#define ASSET TEXT("/Game/MobileStarterContent/Shapes/Shape_Cube_DM.Shape_Cube_DM")
    static ConstructorHelpers::FObjectFinder<USkeletalMesh> asset(ASSET);
#undef ASSET
    if (asset.Succeeded())
    {
        UE_LOG(LogTemp, Log, TEXT("Asset loading succeeded."));

        meshSkel = Cast<USkeletalMesh>(asset.Object);
        meshDest = Cast<UDestructibleMesh>(meshSkel);

        destructible->SetSkeletalMesh(meshSkel, true);
    }

    RootComponent = destructible;
}

How did it help you? I literally copied this code and nothing happens - no physics are simulated, it doesn’t destruct under any circumstances. It just creates an undestructible Skeletal Mesh…

@ashrasmum Maybe this will help you A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums ?