Filling between 2 points

I am making a map generator thing
I need to generate a part inbetween 2 Positions with it being angled to hit both of them

1 Like

aaaaeee
rough example
red being a point

1 Like

I have made it where I can fill between 2 points but the orientation isnt setup
function generate(a, b)

local part = Instance.new("Part")

part.Size = Vector3.new( (a - Vector3.new(b.X, a.Y, a.Z) ).Magnitude, 1, (a - Vector3.new(a.X, a.Y, b.Z) ).Magnitude)

part.Position = Vector3.new(a.X + (a - Vector3.new(b.X, a.Y, a.Z) ).Magnitude / 2, a.Y + (a - Vector3.new(a.X, b.Y, a.Z) ).Magnitude / 2, a.Z + (a - Vector3.new(a.X, a.Y, b.Z) ).Magnitude / 2)

part.Anchored = true

part.Parent = workspace

return part

end

local a = game.Workspace.A

local b = game.Workspace.B

generate(a.Position,b.Position)

Update
made it generate orientation kind of also made a node generator that has a bug that im unsure how it even happened
I put the rblx file down below


progres.rbxl (28.6 KB)

I am once again asking for your help
anyone at all

I am asking again can anyone help

I am asking oncemore if anyone knows how I should do this

image
also epic

Hey man, Iā€™m working on a module for you to use right now, seems like a fun challenge!

1 Like

Finished!

Here is the code!

Tweak with it and learn how it works, let me know if you need anything else!

local filler = {}

local sizeDivision = 1.4 -- Play with this value, but try to keep it around 1.4

local function convertToVector3(P : BasePart?) -- Converts to Vector3 lol
	if typeof(P) == "Vector3" then
		P = P
	elseif typeof(P) == "Instance" then
		P = P.Position
	end
	
	return P
end

function filler.FillPartBetweenPoints(Point1 : Vector3?, Point2 : Vector3?, Thickness : number?) -- Fills the area between two points (part or vector3)
	Point1 = convertToVector3(Point1)
	Point2 = convertToVector3(Point2)

	local newPart = Instance.new("Part")

	local partSize = (Point1 - Point2).Magnitude -- Getting area between Point1 and Point2

	newPart.Anchored = true

	newPart.CFrame = CFrame.new(Point1, Point2) -- Setting position to Point1 and facing towards Point2
	newPart.Size = Vector3.new(partSize / sizeDivision, Thickness, partSize / sizeDivision) -- Setting to correct size
	newPart.Position = newPart.Position + (newPart.CFrame.LookVector * (partSize / 2)) -- Moving half length towards Point2
	newPart.CFrame = newPart.CFrame * CFrame.Angles(0, math.rad(45), 0) -- Rotating to connect corners

	newPart.TopSurface = Enum.SurfaceType.Smooth

	return newPart
end

function filler.CreateLinePartBetweenPoints(Point1 : Vector3?, Point2 : Vector3, Thickness : number?) -- Draws a line between two points (part or vector3)
	Point1 = convertToVector3(Point1)
	Point2 = convertToVector3(Point2)
	
	local newPart = Instance.new("Part")

	newPart.Anchored = true
	
	local lineLength = (Point1 - Point2).Magnitude -- Getting length between Point1 and Point2
	
	newPart.CFrame = CFrame.new(Point1, Point2) -- Setting position to Point1 and facing towards Point2
	newPart.Size = Vector3.new(Thickness, Thickness, lineLength) -- Setting to correct size
	newPart.Position = newPart.Position + (newPart.CFrame.LookVector * (lineLength / 2)) -- Moving half length towards Point2
	
	newPart.TopSurface = Enum.SurfaceType.Smooth
	
	return newPart
end

--[[
	Have fun! :)
]]

return filler
3 Likes

This is a smart solution, I like it

1 Like