LineTraceSingle not picking up terrain?

I’m using this on my player/character that will be used as part of my lock on functions.

FHitResult testHitResult(ForceInit);
	UWorld* TheWorld = this->GetWorld();
	FVector testStartFVector = this->GetActorLocation();
	FVector testEndFVector = testStartFVector + GetActorForwardVector() * 1000.0f;
	FColor debugColor = FColor::Red;

	FCollisionQueryParams TraceParams(TEXT("MyTrace"), true, this);
	TraceParams.bTraceComplex = true;
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;

	if (TheWorld->LineTraceSingle(testHitResult, testStartFVector, testEndFVector, ECC_WorldStatic, TraceParams))
	{
		ALivingEntity* tempActor = (testHitResult.GetActor() != NULL ? Cast<ALivingEntity>(testHitResult.GetActor()) : NULL);

		if (tempActor != NULL)
		{
			//GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Found"));
			debugColor = FColor::Red;
			Target = tempActor;
			//DrawDebugBox(TheWorld, testHitResult.Location, FVector(10, 10, 10), debugColor);
		}

	}

This all works but as it uses my characters direction to do the trace I hadn’t noticed that it ignores terrain as I can actually see the target my self.

I’ve put this code onto my bots, and my bots know the location of their target, so the trace always puts a line straight to them. From their eyes to their targets location.

for some reason they seem to ignore the terrain for collision, any Ideas?

My terrain is set to BlockAll.

Hi, I have the same issue here. My LineTraceSingle seems to ignore walls, building, etc, and find the target trough everything on the level.

Here I use the ECC_Pawn chanel with ECR_Block on Pawn, WorldStatic and WorldDynamic.

Do you have finally found the solution ?

Best regards.

No sorry mate, just really odd. I’ve tried loads of collision channels and different settings none of them work.

Some one on the forum (before the crash) suggest me to use the second overload of the function.

No more ECC_Channel but a FCollisionObjectQueryParams set to AllObjects.

FHitResult Hit(ForceInit);
FCollisionQueryParams TraceParams = FCollisionQueryParams(FName(TEXT("Trace")), true, this);
FCollisionObjectQueryParams TracesParams = FCollisionObjectQueryParams::AllObjects;
[...]
GetWorld()->LineTraceSingle(*Hit, Start, End, *TraceParams, *ExtraParams);

And it works better for me.