I’m tweaking a ocean script I had made for me to make the tween animation have a smooth start. The tween animates the texture on the ocean to make it appear as if it is moving. I set my animation to Sine to create a smooth start, however once the animation ends it resets, creating a jarring visual to the player.
Ideally, I want the animation to continue and not slow down or end, to loop seamlessly after the initial speed up has finished. I have tried starting with a sine tween and then playing a linear tween once the sine tween has finished, however the transition between the two is not seamless.
The code:
local tweens = game:GetService("TweenService")
local texture = Plane.Texture
local moving = false
local movingway = 0
local info = TweenInfo.new(45, Enum.EasingStyle.Sine, Enum.EasingDirection.In, -1)
local infocont = TweenInfo.new(45, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1)
local info2 = TweenInfo.new(10, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false)
local tween = tweens:Create(texture, info, {OffsetStudsU=150})
local tweencont = tweens:Create(texture, infocont, {OffsetStudsU=150})
local tween2 = tweens:Create(texture, info2, {OffsetStudsU=0})
function MoveWaves()
if moving == false then
movingway = 1
moving = true
tween:Play()
wait(45)
tweencont:Play()
else
movingway = 0
moving = false
tween2:Play()
end
end
game.Workspace.Wave.Button.ClickDetector.MouseClick:Connect(MoveWaves)