i know how to spawn a static mesh. but how to do it with destructible meshes?
static mesh:
.h:
UCLASS()
class ASolidBlock : public AActor
{
GENERATED_UCLASS_BODY()
TSubobjectPtr<UStaticMeshComponent> MyBlock;
};
.cpp:
ASolidBlock::ASolidBlock(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
MyBlock = PCIP.CreateAbstractDefaultSubobject<UStaticMeshComponent>(this, TEXT("SolidBlock"));
static ConstructorHelpers::FObjectFinder<UStaticMesh>StaticMesh(TEXT("StaticMesh'/Game/Blocks/SolidBlock.SolidBlock'"));
MyBlock->SetStaticMesh(StaticMesh.Object);
RootComponent = MyBlock;
}
so when i now want to replace “static mesh” with destructible mesh i have several problems.
in the .h file there is UStaticMeshComponent but no UDestructibleMeshComponent…
in cpp this is also a problem and then a UDestructibleMesh has no function SetStaticMesh…
please help
Update:
Mesh = ObjectInitializer.CreateDefaultSubobject<UDestructibleComponent>(this, TEXT("CharacterMesh"));
const ConstructorHelpers::FObjectFinder<UDestructibleMesh> meshObj(TEXT("DestructibleMesh'/Game/Mesh/SM_Player_DM.SM_Player_DM'"));
Mesh->SetDestructibleMesh(meshObj.Object);
RootComponent = Mesh;
gives me the error:
1>C:\Program Files\Unreal Engine\4.6\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h(92): error C2664: ‘void ConstructorHelpers::ValidateObject(UObject *,const FString &,const TCHAR *)’ : cannot convert argument 1 from ‘UDestructibleMesh *’ to ‘UObject *’
can someone help?