How would I detect water level at the player's position?

I have an area trigger currently, that occupies the same space as the body of water. When the player enters the area trigger, an event is fired which triggers an underwater effect.

The problem with this approach is that it is innacurate when the water level is actively changing due to waves generated by gerstner displace.

My question is what would be the most efficient way to actively track the water level at the player’s position and trigger the underwater effect?

Solutions I have thought of so far:

-Use a mesh collider and update the mesh real time based on the water mesh (sounds incredibly inefficient)

-Scrap gerstner displace and keep the water at a predictable level that the area trigger can accurately account for

-Check the mesh vertices closest the player for height and do a check versus the player height (also possibly inefficient)

I’d love to hear the community’s thoughts on this, source engine seemed to figure this out ages ago on pretty tame pc’s.

I would put the water on its own layer and do a ray-cast down from the center of the player.

This is assuming your mesh collider properly tracks your water deformation.

Just found this, definetely not my work or anything! But seems like a very graceful solution for water at first glance :slight_smile:

http://scrawkblog.com/category/water/