Curve beam to go through position

I’m currently attempting to make a beam curve through a position, I was semi close however it isnt exact.

Diagram: (a bit scuffed but it conveys the message)
image

Any help is appreciated!

Bézier curves are achieved like that.

The next thing is to figure out the segments or “resolution” of the curve. The higher the more smoother the curve is, and less makes it more jagged and less smoother.

Subsequently, you’ll find the positions of the segments based on some interpolations. It’s math and it’s just complicated to understand at first hand.

This doesn’t answer my question in any way shape or form.

All you’ve given me is the Wikipedia for bezier curves (which I use often),

I was asking for an answer on how to get a roblox Beam to curve through a desired position using its CurveSize properties and rotating the attachments

Have you tried adding more segments, to see if the problem persists?

This is not my issue, as per my last message.

I see now. What you possibly have to do is, imagine the whole thing as a triangle, where A & B is the position from your beam endings, and C is the point you try to achieve, and then just rotate A & B beam the amount of angles you want the triangle to be. The angles are made up.

Could you elaborate further? Your wording is a bit confusing (Btw the beams follow the RightVector of the attachment really dumb, ik)

You’re talking about these things?

It appears that the way they curve is based on the offset of the red parts here, not from the middle. Not exactly sure how this is calculated, but it does resemble the so-called paths in graphics. It does not exactly make 10 studs away, it also implicitly interpolates back between the central point… maybe?

Beams use cubic bezier, with very weird specifications for curve size which makes this especially confusing, not to mention that instead of coming out the look vector, they come out the right vector

A triangle sum of angles is always 180, you can use this in various ways to achieve your desired A, B & C points of the triangle. It all depends on which corners & edges of the triangle you already know the position, length & angles of.

Got it working to a good enough accuracy,
image

Code:

local target = workspace.TRACER.Target
local origin = workspace.TRACER.Main
local beam = workspace.TRACER.Beam

local zero = Vector3.zero

origin.CFrame = CFrame.lookAt(zero,target.Position) * CFrame.Angles(0,math.rad(90),0)
beam.CurveSize0 = target.Position.Magnitude

I think you don’t think it like Bézier curves. Here’s an image with rotated attachments, with the red pointing direction, circles for some visualization.

It actually works like the way curves are drawn in image editors, it has some similarities. A solution around this is to make a third attachment(and fourth) with opposite rotations. In this image, size is scaled down to 7.5.

Same trick as in the image editor.

Oh never mind, apparently I could also just… (only set CurveSize0, leave the other 0)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.