Advertisement
grannybat

Bezier Curve - Heart [Roblox]

Dec 11th, 2021
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. local function heart()
  2.    
  3.     local function cubicBezier(t, p0, p1, p2, p3)
  4.         return (1 - t)^3*p0 + 3*(1 - t)^2*t*p1 + 3*(1 - t)*t^2*p2 + t^3*p3
  5.     end
  6.  
  7.     local function positions(a, b)
  8.  
  9.         local p1 = Vector3.new(a, 83, 46.5)
  10.         local p2 = Vector3.new(b, 53.5, 46.5)
  11.  
  12.         return p1, p2
  13.  
  14.     end
  15.  
  16.     local left = workspace.Heartbezier.left
  17.     local right = workspace.Heartbezier.right
  18.  
  19.     for i = 1,100 do
  20.         local left = workspace.Heartbezier.left
  21.         local right = workspace.Heartbezier.right
  22.  
  23.         task.wait()
  24.  
  25.         local t = i/100
  26.  
  27.         local p0 = Vector3.new(29.5, 66.5, 46.5)
  28.  
  29.         local p3 = Vector3.new(29.5, 39, 46.5)
  30.  
  31.         local p1, p2 = positions(4.5, -4)
  32.         left.Position = cubicBezier(t,p0,p1,p2,p3)
  33.  
  34.         p1, p2 = positions(54.5, 63)
  35.         right.Position = cubicBezier(t,p0,p1,p2,p3)
  36.  
  37.     end
  38.    
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement