Advertisement
jordan83221

3D Bezier Curves.

Sep 28th, 2015
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.52 KB | None | 0 0
  1. local part=game.Workspace.Part
  2. local p0=game.Workspace.Part1.CFrame
  3. local p1=game.Workspace.Part2.CFrame
  4. local p2=game.Workspace.Part3.CFrame
  5. local t=0
  6. local function rot()
  7.     if t<=1 then
  8.         local pFinalX=math.pow(1-t,2)*p0.X+(1-t)*2*t*p1.X+t*t*p2.X;
  9.         local pFinalY=math.pow(1-t,2)*p0.y+(1-t)*2*t*p1.Y+t*t*p2.y;
  10.         local pFinalZ=math.pow(1-t,2)*p0.Z+(1-t)*2*t*p1.Z+t*t*p2.Z;
  11.         t=t+0.005
  12.         print(t)
  13.         part.CFrame=CFrame.new(pFinalX,pFinalY,pFinalZ)
  14.     end
  15. end
  16. game:service'RunService'.Stepped:connect(function() rot() end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement