How to create a point based on other points positions

I am making a node creation system for a project I am working on, and I have tried many methods that have not succeeded fully (only works when nodes are along certain axis). What I would like to do is to make 2 points based on the position of one, i will explain further ahead:

One point that is 4 studs behind the Mid point (where the start is)
One point that is 4 studs infront of the Mid point (where the end is).

Now usually this would be easy, however I want it to work based on other node’s positioning:

From the distance to the green block and Mid, it only affects the Z axis, resulting in the start node only being affected on the Z axis, 4 studs behind the Mid, however, if the Y axis was to change:


Then so would the Y axis, but only based on where it is.

EXAMPLE
Lets say that the distance in between the green point and mid was 16, on the Z, and 16 on the Y also, 0 on the X, if I want the point to be 4 studs behind / Infront/ the difference, the Start would end up on (0, 12, 12), however, the outcome of the end part is based on the Node infront of it too:

1 Like

Hi Sam, I remember you from YouTube. I’ve been working on improving on your engine, and I may have a solution for this. It isn’t too optimized but it should work for your old system that you had on YouTube. Here is the code. You can change the -2 and 2 to the number of studs you want the path offsetted by.

for Index, Part in pairs(workspace.items.nodes:GetChildren()) do
	local node1 = workspace.items.nodes:FindFirstChild(Part.Name-1)
	local node2 = Part
	local node3 = workspace.items.nodes:FindFirstChild(Part.Name+1)
	
	if node1 and node3 then
		local Middle = Instance.new("Part", node2)
		local End = Instance.new("Part", node2)
		
		Middle.Name = "middle"
		Middle.CanCollide = false
		--Middle.Transparency = 1
		Middle.Size = Vector3.new(0.5,0.5,0.5)
		Middle.Anchored = true
		Middle.CFrame = CFrame.lookAt(node2.Position, Vector3.new(node3.Position.X, node2.Position.Y, node3.Position.Z))
		
		End.Name = "end"
		End.CanCollide = false
		--End.Transparency = 1
		End.Size = Vector3.new(0.5,0.5,0.5)
		End.Anchored = true
		End.CFrame = Middle.CFrame * CFrame.new(0,0,-2)
		node2.CFrame = node2.CFrame * CFrame.new(0,0,2)
	end
end

This does the old node system that you had. I also have a question that you may be able to answer.


All of my turns are fine until there is a turn that is a different direction. The enemy partially does the turn then teleports into the correct position onto the path. I made sure that all of the code is good, but I just cannot seem to figure it out.

1 Like

Sorry, but I have already made a system for it.

Corner turns:

Uphill Turns

The Nodes:

The Original Nodes:

1 Like

Somebody made a module script for those one-point curve turns you’ve been trying to make for a while. BezierPath, an easy to use and optimized spline path module for TD games and general paths

Even if you want to make your code 100% yours, I suggest you use its coding as a reference or smth

mine does it in the exact same way, except mine works for uphill parts aswell.

Bezierpath also works for uphill.

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