LineTrace physical Material Surfacetype Returns Default unless you change bInTraceComplex to false

So I got a very simple line trace to test physical material and custom surface type, basically what it does is to trace object of type Pawn and Player(custom type I added), and depending on the sufaceType I gave them on their physical material I overrided in the details pannel, I print different infomations on the screen:

TArray hitResults;

EObjectTypeQuery Player = UEngineTypes::ConvertToObjectType(ECC_Player);
EObjectTypeQuery Pawn = UEngineTypes::ConvertToObjectType(ECC_Pawn);

//objectType to trace.
TArray<TEnumAsByte<EObjectTypeQuery>> ObjectQueryParams;
ObjectQueryParams.Push(Player);
ObjectQueryParams.Push(Pawn);

FCollisionQueryParams QueryParams("Detection", false, this);
QueryParams.bTraceAsyncScene = true;
QueryParams.bReturnPhysicalMaterial = true;

bool bIsHit = GetWorld()->LineTraceMultiByObjectType(hitResults,
	GetActorLocation(),
	GetActorLocation() + GetActorForwardVector() * 10000,
	FCollisionObjectQueryParams(),
	QueryParams
);
    if (bIsHit)
{
	for (FHitResult Hit : hitResults)
	{
		UPhysicalMaterial* PhysicsMtl = Hit.PhysMaterial.Get();
		if (PhysicsMtl->SurfaceType == SurfaceType_Default)
		{
			FString NameOfHitedObject = Hit.GetActor()->GetName();
			if (GEngine)
			{
				GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, "I see a Normal: " + NameOfHitedObject);
			}
		}
		if (PhysicsMtl->SurfaceType == SURFACE_FANCY)
		{
			FString NameOfHitedObject = Hit.GetActor()->GetName();
			if (GEngine)
			{
				GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, "I see a FANCY: " + NameOfHitedObject);
			}
		}else if (PhysicsMtl->SurfaceType == SURFACE_UGLY)
		{
			FString NameOfHitedObject = Hit.GetActor()->GetName();
			if (GEngine)
			{
				GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, "I see a FANCY: " + NameOfHitedObject);
			}
		}

	}
}

this will work on if I set bInTraceComplex to false in the FCollisionQueryParams. otherwise, I got default surfaceType on everything it hit regardless of the actaully sufaceType I gave them…

Cound any one help me please?

Thanks in advance.

I got it, just set the geometry to use simple collision as complex.

Thank you so much for posting your solution here. I just spent two days dealing with a similar issue until I came to your post. You are my hero for the rest of this week!!! I don’t know why I didn’t think of setting simple collision as complex… I see I got a lot to learn.

Again, thank you!!!

queryParams.bReturnPhysicalMaterial = true;

try this!