I am trying to use Gerstner Wave Function to animate waves.
The waves only animate server side
I cannot figure out any solution
Was following this Youtube video to get the math:
Coding Adventure: Gerstner Waves - YouTube
My code:
-- Using Gerstner Wave function to animate plane
local plane = script.Parent.Plane
local bones = plane:GetChildren()
table.sort(bones, function(a,b) return a.Name < b.Name end)
-- Using Gerstner Wave function to animate plane
local tweenTime = 5 -- time between waves
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(tweenTime, Enum.EasingStyle.Linear)
local startTime = os.clock()
while true do
for key, value in bones do
local deltaTime = os.clock() - startTime
deltaTime *= script:GetAttribute("Speed")
x = math.cos(key-deltaTime)+key
y = script:GetAttribute("Amplitude") * math.sin(x-deltaTime)
local vector = CFrame.new(Vector3.new(0,y,0))
value.Transform = vector
--TweenService:Create(value, tweenInfo, {Transform = vector}):Play()
end
task.wait()
end
Video of current results: