Collision not working on ProceduralMeshComponent

Hey everbody,

I am really frustrated… :frowning:

I create a ProceduralMeshComponent in C++ and it doesn’t overlap / collide with anything, however it blocks the camera and line traces from the mouse…
I set Collision Enabled to Query And Physics, Block all Collision Channels and also set the last boolFlag in GenerateMeshSection to true.

But I tickwise print the number of overlapping Actors / components and it’s always zero, even when I set all channels to ECR_Overlap.
I now tried for two days to solve this and neither the AnswerHub nor people from the chat found the error…

When I pause the game and select the ProceduralMeshComponent it even shows me in the detail-section that everything is set to Block (or overlap, tested both), but neither sweep nor GetOverlapping… ever work… Always empty arrays. I also tried it vice versa, to see if other objects get overlaps from the PMC but neither do they.

What could cause this? Is this an bug?

Here the whole function where I spawn and init it:


void AStaticElementGroup::generateProceduralCollisionComponent(){
	FVector origin(0, 0, 0);
	if (collisionComponent){
		collisionComponent->DestroyComponent();
	}
	UProceduralMeshComponent* PMesh = NewObject<UProceduralMeshComponent>(this, NAME_None);
	
	TArray<FVector> allverts;
	TArray<int32> alltris;
	TArray<FColor> allcolors;
	
       /* generate Triangles code removed */ 
	PMesh->CreateMeshSection(0, allverts, alltris, TArray<FVector>(), TArray<FVector2D>(), allcolors, TArray<FProcMeshTangent>(), true);

	this->SetActorEnableCollision(true);
	PMesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
	PMesh->SetCollisionObjectType(ECollisionChannel::ECC_WorldDynamic);
	PMesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap); // also tried with Block everything, no changes
	PMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera,ECollisionResponse::ECR_Ignore);
	PMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldDynamic, ECollisionResponse::ECR_Overlap);
	//PMesh->SetCollisionProfileName("BlockAll");
	PMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Ignore);
	PMesh->bGenerateOverlapEvents = true;
	ECollisionResponse resp = PMesh->GetCollisionResponseToComponent(PMesh);
	//PMesh->SetCollisionProfileName(TEXT("BotElement"));
	collisionComponent = PMesh;
	//collisionComponent->AttachTo(RootComponent, NAME_None, EAttachLocation::KeepWorldPosition);
	//this->RootComponent = collisionComponent;
}

and here where I try to get the sweep / overlaps:


FHitResult* hit = new FHitResult(ForceInit);
	this->collisionComponent->AddLocalRotation(rot, true, hit,ETeleportType::None);
	TArray<UPrimitiveComponent*> ov;
	TArray<AActor*> oa;
	collisionComponent->GetOverlappingComponents(ov);
	collisionComponent->GetOverlappingActors(oa);
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "OverlapsComp: " + FString::FromInt(ov.Num()));
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "OverlapsActor: " + FString::FromInt(oa.Num()));
	if (hit->bBlockingHit){
		this->collisionComponent->AddLocalRotation(rot.GetInverse());
		this->AddActorLocalRotation(rot.GetInverse());
	}
	else{
		this->collisionComponent->AddLocalRotation(rot.GetInverse());
		this->AddActorLocalRotation(rot);
	}


And yes I am sure the objects I am testing the collision with do block / overlapp. I even tried it with special blocking volumes / overlapp all cubes…

According to your describe, you may not set bCreateCollision in procedural mesh component creat function such as:
MeshComponet->CreateMeshSection_LinearColor(mesh.Index,mesh.Vertices, mesh.Indices, mesh.Normals, mesh.UV0, mesh.VertexColors, mesh.Tangents, true); the last param you may set “false”,If you want collision ,you should set bCreateCollision as true.