Compile of C++ Character gives Assertion failed: BodySetup.IsValid()

Hey Guys

I have a general Character Class that’s created in C++. When I create a Class blueprint of this character the Editor crashes as soon as I press “Compile”. In Visual Studio I get the Assertion failed: BodySetup.IsValid() error.

Here is my C++ code:

AEnemy1::AEnemy1(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	static ConstructorHelpers::FObjectFinder<USkeletalMesh> FriendlyMesh(TEXT("SkeletalMesh'/Game/Character/HeroTPP.HeroTPP'"));
	static ConstructorHelpers::FObjectFinder<UBlueprint> MeshAnimBluePrint(TEXT("AnimBlueprint'/Game/Character/HeroTPP_AnimBlueprint.HeroTPP_AnimBlueprint'"));
	Mesh->SkeletalMesh = (USkeletalMesh*)FriendlyMesh.Object;
	Mesh->AnimBlueprintGeneratedClass = (UAnimBlueprintGeneratedClass*)MeshAnimBluePrint.Object;
	Mesh->RelativeLocation = FVector(0, 0, -88.0f);
	Mesh->RelativeRotation = FRotator(0, -90.0f, 0);
	Mesh->GetMass();
	Mesh->bGenerateOverlapEvents = true;
	Mesh->bUpdateJointsFromAnimation = true;
	Mesh->bEnableUpdateRateOptimizations = true;
	Mesh->SetCollisionObjectType(ECC_Pawn);
	Mesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
	Mesh->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);
	CapsuleComponent->SetCollisionResponseToChannel(ECC_Camera, ECR_Ignore);
	Mesh->OnBeginCursorOver.AddDynamic(this, &AEnemy1::MyOnBeginMouseOver);
	Mesh->OnClicked.AddDynamic(this, &AEnemy1::MyOnClicked);
	CapsuleComponent->OnBeginCursorOver.AddDynamic(this, &AEnemy1::MyOnBeginMouseOver);
	CapsuleComponent->OnClicked.AddDynamic(this, &AEnemy1::MyOnClicked);
}

Any idea what i’m doing wrong ??

Ok I solved it, I had to change the collision presets to “Block All”. For some reason the above settings made the editor to crash. A bug perhaps ??

Is there anyway I can set a “Collision Preset” to Block All via C++ ?

Set “Collision Preset” to Block All in C++

Mesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);