I want to make this beam curve around terrain and parts using PathfindingService or something similar, to make the beam follow a spline-path to the location. Anyone know how I can put multiple points on a beam?
(I’ve looked on the forum, and all I can find about pathfinding is for NPCs, and all I can find about beams is straight lines or single/double curves, so I don’t know where to look)
That’d be really neat, but unfortunately as far as I’m aware that isn’t possible using the Roblox beam object. Probably would require a bit of math to do it otherwise, definitely not the guy to tell you how unfortunately
local PathfindingService = game:GetService("PathfindingService")
local endpoint = workspace.endpoint
local startpoint = workspace.startpoint
local path = PathfindingService:CreatePath()
path:ComputeAsync(startpoint.Position, endpoint.Position)
local waypoints = path:GetWaypoints()
local Folder = Instance.new("Folder")
Folder.Name = "Waypoints"
Folder.Parent = workspace
for i, v in ipairs(waypoints) do
local Part = Instance.new("Part")
Part.Position = v.Position
Part.Anchored = true
Part.Size = Vector3.new(1, 1, 1)
Part.Parent = Folder
if (i > 1) then
local lastWaypoint = waypoints[i - 1]
local dist = (v.Position - lastWaypoint.Position).Magnitude
local Part2 = Instance.new("Part")
Part2.Anchored = true
Part2.BrickColor = BrickColor.Black()
Part2.Size = Vector3.new(.5, .5, dist)
Part2.CFrame = CFrame.new(lastWaypoint.Position, v.Position) * CFrame.new(0, 0, dist / -2)
Part2.Parent = Folder
end
end