How is the beam curve property calculated and how would you use it to model a quadratic bezier curve?
Roblox uses cubic bezier curves for beams
On the wiki page for beams it describes the curve sizes being calculated as:
P0 : The start of the beam, the position of
Beam.Attachment0
P1 :Beam.CurveSize0
studs away fromBeam.Attachment0
, inBeam.Attachment0
’s positive X direction.
P2 :Beam.CurveSize1
studs away fromBeam.Attachment1
, inBeam.Attachment1
’s negative X direction.
P3 : The end of the beam, the position ofBeam.Attachment1
Calculating these positions should be pretty self explanatory and would just involve multiplying the attachments CFrame by CFrame.new(curvesize0,0,0) or CFrame.new(-curvesize1,0,0)
You would then just use the bezier formula to complete the problem
function B(t,p0,p1,p2,p3)
return (1 - t)^3*p0 + 3*(1 - t)^2*t*p1 + 3*(1 - t)*t^2*p2 + t^3*p3
end
beam.Parent.CFrame * B(t,attachment0.Position,(attachment0.CFrame*CFrame.new(curvesize0,0,0)).p,(attachment1.CFrame*CFrame.new(-curvesize1,0,0)).p,attachment1.Position)
Results in something like
Ah, i meant like how could you set the beam’s curve properties to a certain bezier curve not using it as a trajectory but using it as a projectile tracer.
I got it to work by just doing the inverse of that. lol.
Hey would you mind explaining how you got it to work Mr. Ratius Rat? Thanks.
Difficult to explain but essentially what you’re trying to do is changing the CFrame relative to the attatchment’s right vector and since it’s only quadratic i only edited the curvesize 1.
Hm Do you have a video of how your tracers came out looking? (Visually) Thanks for responding.