Hello I know this is a semi mathy question, however, every forum post I’ve tried to use for this hasn’t been able to accomplish my goals.
Goals: I want my model that has a primary part to rotate along with the bezier curve as it’s following the path.
Here’s my code:
function NukeModule:LaunchNuke(nuke)
local PathFolder = workspace:WaitForChild("Path")
local start = PathFolder:WaitForChild("Start").Position
local finish = PathFolder:WaitForChild("End").Position
local p1 = PathFolder:WaitForChild("p1").Position
local p2 = PathFolder:WaitForChild("p2").Position
local function lerp(a,b,t)
return a + (b-a) * t
end
for i = 0, 500, 1 do
local t = i/500
local l1 = lerp(start, p1, t)
local l2 = lerp(p1, p2, t)
local l3 = lerp(p2, finish, t)
local start = lerp(l1, l2, t)
local finish = lerp(l2,l3,t)
local cubic = lerp(start, finish,t)
nuke:SetPrimaryPartCFrame(CFrame.new(cubic))
task.wait(.01)
end
end