Hi guys.
I don’t like the indie water plane that comes with Unity, so I though I’d improve it.
I’ve written a script that periodically uses the Perlin noise generator to generate new vertical positions for the vertices in the water plane mesh, then Lerps the vertices over time to make the water move up and down like waves.
It works really well (well, I’m happy with it), but now I want to put boats on my newly moving water.
I thought to start with I could just use a raycast on the boats going straight down, and use the raycast.hit to create a new position. This doesn’t work though, since I’ve disabled the collider for the water, and anyhow the collider is fixed and doesn’t move with the surface of the waves. What I really need is one of two things. Either:
- find out how far above the surface of the water the boat is, using some other method
or
- find a way to sample the Vector3 where a point on the boat intersects the mesh of the plane and use that to change the position of the boat.
Or some third thing I can’t think of!
Can anybody help me please? Any help greatly appreciated, thankyou.