LineTraceSingleByChannel - how to generate hit at water surface?

Hello! We’re trying to send out a lot of rays and see where it collides in the world, and as of now, it works well for static geometry and actors. It was requested to generate a hit upon impacting a WaterBodyLake object as well, and we’re struggling to find a solution, even though we feel like we’re missing something simple.

The water has dynamic waves, and ideally this should impact the exact location of the hit, but as of now the line trace just passes through the water surface and hits the lake bed.

We’re unsure how to progress, and any help is greatly appriciated!

Currently in the code we have:

// ... other stuff
queryParam = FCollisionQueryParams::DefaultQueryParam; queryParam.bTraceComplex = true;
queryParam.bReturnFaceIndex = true;
bHit = GetWorld()->LineTraceSingleByChannel(hitResult, traceStart, traceEnd, ECollisionChannel::ECC_Visibility, queryParam, FCollisionResponseParams::DefaultResponseParam);

3 ways I think of:

  1. The water surface is ignored by the line trace because of an incorrect collision setup. This would be the first thing to see if you can fix it.
  2. Possibly the water has no (or no accurate) collision mesh and is just a visual effect to get the waves on screen. In that case you might get the wave height on an X Y position by reading the data which generates the wave (usually math or a displacement map in a shader).
  3. There’s a very experimental water plugin shipped with UE I believe it is called Buoyancy, see if you can get an example there, it reads wave height for buoys.