I have a slight suspicion that bizier curves are involved with this, the over all smoothness of it impresses me and I would like to know how it was done. Any thoughts?
Bézier curves are used in this case. The particle object is following the path of this curve.
Tweening, Trails, ParticleEmitters.
Do you have any tutorials on bezier curves? I’ve tried EgoMoose’s but there quite complicated.
Unfortunately not, it’s almost like another math lesson. Look a little into it.
Bezier curves use three points to calculate a curve
Point 1 - The origin
Point 2 - The Curve Influence
Point 3 - The End Location
There’s more to it but that’s the base concept of it (I usually put the API page at the top of my scripts, use that to see more.)
They can be a pain so I made a function I can use.
Heres what I did at one point to make curves:
--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
https://developer.roblox.com/en-us/articles/Bezier-curves
This is a tutorial, but like you said, if someone want to understand this really you need to understand the base of the math used here.
I agree, enjoy the migraines caused by this messy API
There will be more information out there aside from the API like educational sites used for A level mathematics.
What does Inc represent? I was thinking it was how much the points are spaced out by but I’m not sure.
edit: nvm thank you so much you explained that better for me in 50 lines then EgoMoose did in 500.