Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Minis Curve Creating Script (UnderDev)
- --https://developer.roblox.com/en-us/articles/Bezier-curves
- -- T is a decimal below 1, 1 means curve is completed
- --So smaller intervals means more points and smoother creation
- --P1 Is midpoint
- --P0 and P2 are the start and finish
- --Uses Pythag and current position + %Complete
- --V1
- function lerp(a,b,c)
- return a + (b - a) * c
- end
- --Lerps All the points
- function CurvePoint(p0,p1,p2,t)
- t = t
- --LERP X
- Xl1 = lerp(p0.X, p1.X, t)
- Xl2 = lerp(p1.X, p2.X, t)
- XLerp = lerp(Xl1, Xl2, t)
- --LERP Y
- Yl1 = lerp(p0.Y, p1.Y, t)
- Yl2 = lerp(p1.Y, p2.Y, t)
- YLerp = lerp(Yl1, Yl2, t)
- --LERP Z
- Zl1 = lerp(p0.Z, p1.Z, t)
- Zl2 = lerp(p1.Z, p2.Z, t)
- ZLerp = lerp(Zl1, Zl2, t)
- Pos = Vector3.new(XLerp,YLerp,ZLerp)
- return Pos
- end
- -- Simplify Curve
- -- T should usually be 0
- function CreateCurve(p0,p1,p2,t,Inc)
- Points = {}
- t = t
- LoopCount = 0
- while t < 0.99 do
- CurvePoint(p0,p1,p2,t)
- Points[LoopCount] = CurvePoint(p0,p1,p2,t)
- --Keeps Track Of Progress
- LoopCount = LoopCount + 1
- t = LoopCount * Inc
- end
- return Points
- end
- function test()
- print("test")
- p0 = game.Workspace.p0.Position
- p1 = game.Workspace.p1.Position
- p2 = game.Workspace.p2.Position
- t = 0
- Inc = 0.02
- Curve = CreateCurve(p0,p1,p2,t,Inc)
- for i = 1,#Curve do
- Point = Curve[i]
- NewPart = Instance.new("Part",game.Workspace.Test)
- NewPart.Size = Vector3.new(1,1,1)
- NewPart.Transparency = 0.5
- NewPart.Anchored = true
- NewPart.Position = Point
- wait(0.1)
- end
- end
- test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement