Using Editor's tool in Code

You don’t ever assign a value to the cloth pointer.

This is general tip for constructors, constructor is executed when engine and object is not fully initiated, some function may behave strangly or cause crashes, if that happens try to move code to PostInitializeComponents (executes in both level editor and play) or BeginPlay (executes only in play mode) events. In general practice constructor should only set default settings

But current cause is what say, all not initiated pointers are either nullptr or invalid.

so i finally figured out how to create Skeletal Actor in C++ code,

now i want to use UE4 Editor’s Clothing tool in C++.

below code is what i tryed :

Header

class C_TEST07_API AMyActor : public AActor
{
	GENERATED_BODY()
	...
	public:
		UClothingAssetBase* cloth;
}

Source

AMyActor::AMyActor()
{
	PrimaryActorTick.bCanEverTick = true;
	
	MySkeletalMesh =
		CreateDefaultSubobject<USkeletalMeshComponent>(FName("MySkeletalMeshComponent"));

	ConstructorHelpers::FObjectFinder<USkeletalMesh> SK_mannequin(TEXT("SkeletalMesh'/Game/mesh/mannequin.mannequin'"));
	
	RootComponents = MySkeletalMesh;
	
	MySkeletalMesh->SetSkeletalMesh(SK_mannequin.Object,true);
	skinnedMesh = MySkeletalMesh;
	
	cloth->BindToSkeletalMesh(skinnedMesh->SkeletalMesh, 1, 1, 1);
}

its crash when i compile it

probloms codes are this:

cloth->BindToSkeletalMesh(skinnedMesh->SkeletalMesh, 0, 0, 0);

error said :

this->cloth was nullptr

so i guess i might be use wrong way. anyone can fix my probloms?

Thanks.