Help with procedurally generated skill tree

Hello, I’m working on a chemistry game and I’m trying to make a procedurally generated skill tree so the players can easily look up what chemical to make next.
image
But as you can see, I don’t know how to limit the angles so they stop overlapping.
I would like the nodes to go around the main chemical in full 360 degrees (which they already do)
But I need a way to limit the angles of secondary nodes:
image
(do not steal my masterpiece artwork, I forgot to watermark it)

This is my code:

local function makeTree(ID: number, sT: GuiObject, prev: GuiObject?): ()
	if not sT then return end
	local Pages, PgAMT = getPages(ID)
	local i = 0
	local angle = 360 / (PgAMT[cPage] or 1)
	for Item, Combinor in pairs(Pages[cPage] or {}) do
		i += 1
		local Line = Instance.new("Frame")
		Line.Size = UDim2.new(0, L_SIZE, 0, 5)
		Line.AnchorPoint = Vector2.new(.5, .5)
		Line.Rotation = (i + (prev and 1 or 0)) * angle
		Line.Position = sT.Position
		Line.ZIndex = 0
		Line.BackgroundColor3 = Color3.fromRGB(22, 28, 36)
		local x, y =
			L_SIZE * math.cos(math.rad(Line.Rotation)),
			L_SIZE * math.sin(math.rad(Line.Rotation))
		local sX, sY = sT.Size.X.Offset, sT.Size.Y.Offset
		Line.Position += UDim2.new(0, x - x / 3, 0, y - y / 3)
		Line.Parent = SkillTree
		Kill[sT] = Kill[sT] or {Rely = Kill[prev]}
		table.insert(Kill[sT], Line)
		local sT2 = STemplate:Clone()
		sT2.Icon.Image = SubstanceManager.IDs[Item].Main.Info.Icon.Texture
		sT2.Position = sT.Position + UDim2.new(0, x, 0, y)
		sT2.Name = Item
		sT2.Parent = SkillTree
		table.insert(Kill[sT], sT2)
		makeTree(Item, sT2, sT)
	end
end

The “get pages” function returns a table of every secondary node that has to be attached to the given node.
Then it creates a secondary node and a connecting line and rotates, offsets them.
The kill table is just a fancy way of cleaning the nodes.

Any help appreciated!

You used chatgpt which is shameful, and to make it worse, it doesn’t work of course.
I would advise you to not use chatgpt to answer these questions, cause AI isn’t that good yet, and you would benefit from leaning this more than just getting a solution mark on your profile.

Anyways, thanks for your time.

I made some progress, they are rotated properly now:
image

But I don’t know how to fix this mess:
image

It happens because there are multiple recipes for one substance, so that one substance then spreads out and creates nodes on what you can get next, but there will be multiple of the same substances shown.

Nvm I solved it by filtering stuff. No help needed after all…

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