How to do a shape trace for the landscape actor?

Hi, I had posted this same question on answerhub but its been a week and still no response. So, I decided to post it on the forum instead.

I need to find the Z value of the surface of the landscape at a XY coordinate. The way I am currently achieving this is by using the code below.


1. if (landscape->ActorLineTraceSingle(hitResult, vector1, vector2, ECC_Visibility, collisionParams)
2. {
3.      Z = hitResult.Location.Z;
4. }


However, I had found out that line tracing a landscape can result in a bug where the trace just passes through the landscape without producing a hit. So, I would like to do a shape/sphere trace instead but I cannot seem to find any function that does such a trace for an actor.

I have tried implementing sphere trace using the following code:


1. if (world->SweepSingle(hitResult, vector1, vector2, FQuat(), ECC_GameTraceChannel1, FCollisionShape::MakeSphere(10), collisionQueryParams, FCollisionResponseParams())
2. {
3.      Z = hitResult.Location.Z;
4. }


ECC_GameTraceChannel1 is a custom trace channel made to be ignored by all except the landscape. Using either ECC_GameTraceChannel1 or ECC_Visibility seems to make no difference.

Using the code above to do sphere traces, even more traces managed to pass through the landscape than before. Anyone has any idea what is wrong?