Is there a way to get the position of points in a beam?

Is there a way to get info of all the points/segments of a beam? Like, for example:

local segments = Beam:GetSegments()

for i, seg in segments do

Or something similar.

Any help is highly appreciated!

You have to write your own code for it.

Roblox beams use the Cubic Bezier Curve.

My sample code for the demo. I use my own debug module system to draw the dots.

local DEBUG = require(game.ReplicatedStorage.GameLib.DebugModule)

local beam = script.Parent.Beam

local function beamPos(beam: Beam, t: number)
	-- get the bezier position of the beam given the percentage t
	local p0 = beam.Attachment0.WorldCFrame
	local p1 = p0 * * beam.CurveSize0,0,0)
	local p3 = beam.Attachment1.WorldCFrame
	local p2 = p3 * * beam.CurveSize1,0,0)

	p0 = p0.Position
	p1 = p1.Position
	p2 = p2.Position
	p3 = p3.Position
	return (1 - t)^3 * p0 + 3 * (1 - t)^2 * t * p1 + 3 * (1 - t) * t^2 * p2 + t^3 * p3

while task.wait(0.1) do
	for i = 1,beam.Segments do-- draws out point of the segment
		DEBUG.drawVector3(beamPos(beam, i/beam.Segments)) 

Exactly what I needed. You’re a life saver. Thanks!

1 Like

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