Been trying to get ray trace to return every actor hit. I am using UShapeComponents for collision detection, I disable every channel on my meshes and activate them on the ShapeComponents instead. I am using ECR_Overlap but I am getting nothing hit. I tried making the ECC_ObstacleChannel block but it only returns one of the actors that get hit, not even the first (might depend how they get added to the scene). Any idea what is missing? Thanks.
void IObstacleInterface::BeginObstacle()
{
GetMeshComponent()->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
ShapeComponent = GetCollisionShape();
ShapeComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
}
In the Tick event…
TArray<FHitResult> ObstacleHitResults;
ObstacleHitResults.Init(FHitResult(ForceInit), 3);
FCollisionQueryParams ObstacleCollisionQueryParams = FCollisionQueryParams(FName(TEXT("Trace")), true, MeshComponent->GetAttachmentRootActor());
ObstacleCollisionQueryParams.bTraceComplex = false;
ObstacleCollisionQueryParams.bReturnFaceIndex = false;
ObstacleCollisionQueryParams.bReturnPhysicalMaterial = false;
ObstacleCollisionQueryParams.AddIgnoredActor(OverlappedObstacle);
FCollisionResponseParams CollisionResponseParams = FCollisionResponseParams(ECollisionResponse::ECR_Overlap);
if (MeshComponent->GetWorld()->LineTraceMultiByChannel(ObstacleHitResults, Current + FVector(0, 0, 50), Target + FVector(0, 0, 50), ECC_ObstacleChannel, ObstacleCollisionQueryParams, CollisionResponseParams))
{