Tracing FHitResult Not Consistently Returning SurfaceType

Hello all,

I have an issue that is very perplexing to me that I hope I can receive some help with. I am working to create gameplay behavior that checks a hit actor/component’s Material.PhysicalMaterial.SurfaceType in order to implement gameplay behavior. In this case I am performing a LineTraceSingle which is set to return the PhysicalMaterial in its CollisionQueryParameters. My code is as so:

FCollisionQueryParams CollisionQueryParams = FCollisionQueryParams(GetClass()->GetFName(), false, NULL);
CollisionQueryParams.bReturnPhysicalMaterial = true;
CollisionQueryParams.bTraceComplex = false;
CollisionQueryParams.AddIgnoredActor(UTOwner);

GetWorld()->LineTraceSingle(Hit, StartLocation, EndTrace, TraceChannel, CollisionQueryParams))

However when I test this code in game, I get perplexing results. Using a single actor with a single material applied, sometimes the results differ! I have attached screenshots below.

Legend:
White Line: Initial trace
Green Line: Normal of surface
Blue Line: Reflection vector

Here is a screenshot of a successful test:

The white line indicates the initial trace, the green line I am drawing to check the normal of the hit actor, and the blue line indicates success by drawing the reflected vector of the trace.

In this image you can see that no reflection occurred. When I set a breakpoint in Visual Studio I can see in this case that the check I am performing when I execute my trace,

if (OutHit->PhysMaterial->SurfaceType == ReflectiveSurfaceTypes[j])

Is returning false. This is very perplexing as I have applied this material to the box myself and know that this is the correct PhysMaterial and SurfaceType. This is the exact same box and material as in the first screenshot, so why it fails in one case and not the other is very confusing. Any ideas?

Just to add further information here:

  • I am checking the value of my LineTraceSingle. It returns true.
  • Based on further testing it seems that this behavior (where the FHitResult does not have the correct values for the PhysicalMaterial) occurs most frequently when I am shooting at a steep downward angle. I suspect that somehow the Character’s capsule is blocking the trace somehow, even though it was added to the list of ignored actors.