Problems with my Wave Module

Hello
I have descended into the watery grave known as “Gerstner Wave” water systems,
This is like day 12 of my work. Currently I have a really efficient graphical part of the module, which (on my computer) averages ~2-3.5 ms.
The module has a commented tutorial at the top on how to set it up, but right now I have two problems with the module:
1: My floatation function sucks, and doesn’t support rotation along the y axis of the floating object.
2: I have a whirlpool manipulation that doesn’t work.

with 1, this is my floatation function:

        Size = Size or Vector2.new(3, 3)
		Position = Vector3.new(Position.X, Controller.WaterHeight, Position.Z)
		
		local Pos_1 = Position + Vector3.new(Size.X/2, 0, Size.Y/2) --Corner 1
		local Pos_2 = Position + Vector3.new(Size.X/2, 0, -Size.Y/2) --Corner 2
		local Pos_3 = Position + Vector3.new(-Size.X/2, 0, -Size.Y/2) --Corner 3
		
		local Pos_1w = Pos_1 + module:GenerateGerstner(Pos_1, Controller.Steepness, Controller.Speed, Time)
		local Pos_2w = Pos_2 + module:GenerateGerstner(Pos_2, Controller.Steepness, Controller.Speed, Time)
		local Pos_3w = Pos_3 + module:GenerateGerstner(Pos_3, Controller.Steepness, Controller.Speed, Time)
		--Add on the wave alter
		for _, Manip in ipairs(Mods) do
			Pos_1w = Manipulator:Manipulate(Manip, Pos_1, Pos_1w)
			Pos_2w = Manipulator:Manipulate(Manip, Pos_2, Pos_2w)
			Pos_3w = Manipulator:Manipulate(Manip, Pos_3, Pos_3w)
		end--For manipulations
		
		local Pos_1C2 = Pos_1w/2 + Pos_2w/2
		local Pos_2C3 = Pos_2w/2 + Pos_3w/2
		--Two sides
		local M = Vector3.new(Pos_2C3.X, Pos_1C2.Y / 2 + Pos_2C3.Y / 2, Pos_1C2.Z)
		--Middle of the sides
		local LV1 = -(M - Pos_1C2).Unit --Vector looking at Side 1
		local LV2 = -(M - Pos_2C3).Unit --Vector looking at Side 2

		local UV = LV1:Cross(LV2) --Vector looking up
		
		return (CFrame.Angles(UV.X, 0, UV.Z) + M) --Returned CFrame, gets applied to the part thats floating.

Right now it doesn’t support the input for the Y rotation of the object, and the floatation isn’t the best.

For the whirlpool:

        local WayCent = (Dist/Manipulation.Magnitude.Value)
		local AlterVector = Vector3.new(0, ((Manipulation.Magnitude.Value/2)*(1-WayCent)), 0)
		AlteredPos = AlteredPos*WayCent
		AlteredPos = AlteredPos - AlterVector --Altering the already existing changes
		local a = (TruePos - Manipulation.Value).Unit --Vector looking at the middle of the whirlpool
		local b = a:Cross(Vector3.new(0, 1, 0)).Unit --Vector looking to the right of the middle of the whirlpool
		local c = GerstnerWave(TruePos, 290, Vector2.new(b.X, b.Z), 0.15, 0.022, tick()+((1-WayCent)*3)) --Wave Generated with the b vector
		c = c*(1-WayCent) --Making the addition weaker the farther it is from the middle
		AlteredPos = AlteredPos + c --Adding it on to return

TruePos → UnAltered bone position
AlterVector → Pre-Altered bone position
Manipulation.Value → Whirlpool center

Here’s the module: Wave2(beta-v3).rbxm (12.3 KB)

2 Likes