Hi,
I’m using the following snippet for surface detection of Landscapes, to get height and slope values for my tile based pathfinder, where tile size matches landscape mesh resolution. Normally it works fine, except on landscape chunk edges where no collision detection works, but only along the X axis, and only on relatively horizontal surfaces! It was the same with 4.8 and 4.7 too.
No landscape thickness increase helps, I currently use a little Y offset value as a workaround. I hope it could be resolved soon, as in some cases I cannot work safely with offsets…
float ARTSMapSystem::GetLandTerrainSurfaceAtCoord(float XCoord, float YCoord)
{
FCollisionQueryParams TraceParams(FName(TEXT("GroundObjectSurface")), false, this); // TraceTag (info for debugging), bTraceComplex, AddIgnoredActor
//TraceParams.AddIgnoredActor(this);
//TraceParams.bTraceComplex = false; // no true works to avoid landscape mesh border errors... a small xy offset is needed, and used on tile min-max (slope) check
TraceParams.bTraceAsyncScene = true;
TraceParams.bReturnPhysicalMaterial = false;
FHitResult Hit;
FVector Start = FVector(XCoord, YCoord, MaxTerrainHeight);
FVector End = FVector(XCoord, YCoord, MinTerrainHeight);
// ECC_ channels should be set !!!
bool bHit = GetWorld()->LineTraceSingleByChannel(Hit, Start, End, ECC_LANDTERRAIN, TraceParams);
if (bHit)
{
return Hit.ImpactPoint.Z; // or Location?
}
return (float)NO_Z_APPLIED;
}