I just came up with a small script to animate a sine wave. It works fine, but, I figured extending the amount of parts involved would essentially ‘detail’ the sine wave more, but instead the sine wave just replicates itself.
What it does:
The code:
local array = {}
local gamestarted = tick()
for i = 1,20 do
local part = Instance.new("Part")
part.Position = Vector3.new(i,0,0) + Vector3.new(0,5,0)
part.Size = Vector3.new(1,1,1)
part.Anchored = true
part.Parent = workspace.Parts
table.insert(array, part)
end
while wait() do
for index, part in pairs (array) do
part.Position = Vector3.new(part.Position.X, 5, part.Position.Z) + Vector3.new(0, math.sin(tick() - gamestarted + index) / 2, 0)
end
end
What I want:
The sine wave to instead utilize all the parts to generate the length of 1 wave
local array = {}
local gamestarted = tick()
for i = 1,90 do -- size of wave
local part = Instance.new("Part")
part.Position = Vector3.new(i,0,0) + Vector3.new(0,5,0)
part.Size = Vector3.new(1,1,1)
part.Anchored = true
part.Parent = workspace.Parts
table.insert(array, part)
end
while wait() do
for index, part in pairs (array) do
part.Position = Vector3.new(part.Position.X, 5, part.Position.Z) + Vector3.new(0, math.sin(tick() - gamestarted + index) / 2, 0)
end
end
local array = {}
local gamestarted = tick()
for i = 1,90 do -- size of wave
local part = Instance.new("Part")
part.Position = Vector3.new(i,0,0) + Vector3.new(0,45,0)
part.Size = Vector3.new(1,1,1)
part.Anchored = true
part.Parent = workspace.Parts
table.insert(array, part)
end
while wait() do
for index, part in pairs (array) do
part.Position = Vector3.new(part.Position.X, 45, part.Position.Z) + Vector3.new(0, math.sin((tick() - gamestarted + index / 10)) * 8, 0)
end
end