Greetings!
Recently I’m trying to do a funny little animation of a boat arriving to a dockyard but every time it moves between waypoints the orientation changes which makes it look weird. This is how it looks like https://gyazo.com/01981a7c8dc229b568f4ace051f6a30b
Ignore the fact that the code may be a little bit messy, I am just messing around to see how I’ll work this system. I’m very new to TweenService and I can’t spot the problem myself.
Code that handles the Tween:
local function Route(spawnArea, boatModel)
local boatCore = boatModel.Core
if spawnArea == 'Spawn1' then
local currentWaypoint = 1
local waypoints = script.Parent.Routes.Dock1
local amountWaypoints = waypoints:GetChildren()
for i = 1,(#amountWaypoints - 1),1 do -- Will aim and go towards a waypoint
for i = 0,1,0.01 do -- Will look at waypoint
wait()
local NewPosition = boatModel:GetPrimaryPartCFrame():Lerp(CFrame.new(boatModel.PrimaryPart.Position, waypoints[tostring(currentWaypoint)].Position), i)
boatModel:SetPrimaryPartCFrame(NewPosition)
end
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local readyTween = tweenService:Create(boatModel.PrimaryPart, tweenInfo, {CFrame = waypoints[tostring(currentWaypoint)].CFrame})
readyTween:Play()
readyTween.Completed:wait()
currentWaypoint += 1
end
end
end