Get height of wave using gerstner

i used this Realistic Oceans Using Mesh Deformation! - Resources / Community Tutorials - DevForum | Roblox to get the wave movement working but it didnt have a get height function and i cant figure out how to get it

this is my current function (i looked all through the page to see if someone made a height function)

function Wave:GetHeight(pos)
	local WorldPos = pos
	local Settings = self._settings
	local Direction = Settings.Direction

	if Direction == EmptyVector2 then
		-- Use Perlin Noise
		Direction = Vector2.new(math_noise(WorldPos.X/NoiseModifier,WorldPos.Z/NoiseModifier,1),math_noise(WorldPos.X/NoiseModifier,WorldPos.Z/NoiseModifier,0))
	else
		Direction = GetDirection(Settings,WorldPos)
	end
	
	return Gerstner(WorldPos,Settings.WaveLength,Direction,Settings.Steepness,Settings.Gravity,self._time)
end

this is what i do to move the part in the video

local height = self:GetHeight(self._instance.Parent.Part.Position)
self._instance.Parent.Part.Position = height

video:

does anyone know how to get the height of the wave

Just shoot a raycast down with ocean only whitelisted. And you will get Y of that point. If you need me to explain or make a script for that, lemme know.

its not part its a mesh using bones

I know, but im not sure if Raycast hits deformed meshes, so you can try.

they dont raycast only care about parts and terrain not deformed meshes

1 Like

found the solution, not going to give it away

That’s annoying so instead i’m going to do this for those looking for help :slight_smile:

3 Likes