Hey, I've been working on boat physics, and I was experimenting with smooth terrain water.
It was going great...
...until the water was going over the raft, and making it look unrealistic.
local x, z = 0, 0
game:GetService("RunService").RenderStepped:connect(function()
y = 1.8 * math.sin((math.pi * 2) / 85 * x * game.Workspace.Terrain.WaterWaveSpeed / 10) * math.sin((math.pi * 2) / 85 * z * game.Workspace.Terrain.WaterWaveSpeed / 10) + 15
x = x + 0.18
z = z + 0.18
script.Parent.Position = Vector3.new(0, y, 0)
end)
I've tried that, but it never seems to correctly float; it's either too fast or too slow. The original tweet I got this from is this

15 comments
wow much math
might need someone smart to post an answer
Would you elaborate on what you mean by too fast or too slow? How much faster or slower is it compared to the actual waves?
Not sold on this formula. Everywhere x%85 = 0, the water wave height does not change but this equation does not account for this. Also the wave height should be dependent on time, not (x, z) coordinates. This is likely an approximation that works with values close to 0 but not points much further away. Nonetheless, quite a tricky problem without knowing the actual implementation.
The wave height is dependent on time since x and z are dependent on time. And y(x, z) in all locations is also changing constantly with time. I think the problem is syncing, assuming the tweet Firefaul linked is correct.
X and Z are not positions. The values are 0, and they are not related to position.
It may have seemed that way with the way I had the code set up.
Also, if I just had it as time alone, and did nothing with the position, that would still mess it up, because the raft would be moving.
And yes, @honeygold13843, the problem is syncing the bobbing to the waves themselves; it's always ahead or behind, no matter how I change it.
Is the wave height set to 1?
Yes @script_help.
Did you try using rays? Might sound stupid but it can help.
Adding rays front, back and sides of boat(To every corner) to infront of parts can give you position of next wave and get wave's size under your ship. Takes long time, sounds stupid, looks ugly, but can handle your problem :)
Actually, rays think of water as just a solid square; the waves aren't part of the hitbox.
idk, the script looks like right