Help with pathfinding?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?

I want to achive something that looks like this

  1. What is the issue?

Im not sure how to do this as my attempt looks like this:

It work but not how I want it to it paste loads of parts etc.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local PathfindingService = game:GetService("PathfindingService")
local PathfindingServiceCreatePath = PathfindingService:CreatePath()

local AlreadyPro = workspace.AlreadyPro

PathfindingServiceCreatePath:ComputeAsync(AlreadyPro.HumanoidRootPart.Position, workspace.End.Position)

local PathfindingServiceCreatePathGetWaypoints = PathfindingServiceCreatePath:GetWaypoints()

function Function(Number, Part, Part2)
	local Folder = Instance.new("Folder")
	Folder.Name = "Part" .. Folder.Name
	Folder.Parent = workspace
	
	local Parts = {}
	for Number2 = 0, Number do
		local Vector = Part.Position + (Part2.Position - Part.Position).Unit * Number2 * (Part.Position - Part2.Position).Magnitude / Number
		
		--[[
		local Part3 = Instance.new("Part")
		Part3.Position = Vector
		Part3.Anchored = true
		Part3.Size = Vector3.new(1, 1, 1)
		Part3.Parent = Folder
		
		--]]
		
		Parts[#Parts + 1] = Vector
	end
	
	for Number3 = 1, #Parts do
		if Parts[Number3 + 1] ~= nil then
			local Part4 = Instance.new("Part")
			Part4.CFrame = CFrame.new((Parts[Number3] + Parts[Number3 + 1]) / 2, Parts[Number3 + 1])
			Part4.Anchored = true
			Part4.Size = Vector3.new(1, 1, (Parts[Number3] - Parts[Number3 + 1]).Magnitude)
			Part4.Parent = workspace
		end
	end
end

for i, waypoint in pairs(PathfindingServiceCreatePathGetWaypoints) do
	Function(i, AlreadyPro.HumanoidRootPart, workspace.End)
end

That is my code I want to know how to turn it into an efficient one like the mc pathfinding line.

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Any help would be nice

Hi, I’m not too drastically experienced in pathfinding with my 4 years of experience, its something I have kinda glanced at but not delved into. I believe the way minecraft achieves the path finding is by taking the player’s position then going in all directions and finding all blocks that a player can reach, e.g the one they step too, the next block along by hopping and then so on until the player’s max jump distance is reached. then the program iterates through that until a possible path is found then from there better and better ones are created by essentially trial and error but they just happen that fast you only really see the end result. I would code the iterating block atm, but like I said I have limited experience and rn not a lot of time on my hands so if someone else could write it out or even have a crack yourself that would be even better. but a quick psuedocode of it would be:

BEGIN
     -- Variables
     INPUT Part_Coordinates
     INPUT Player_Coordinates
     INPUT Player_Range
     -- Obtaining the grid
     WHILE
          -- Check within a CUBE of the player for part instances, Cube as Roblox is 3d and can also allow for elevation changes.
          -- You will want to store each 1x1x1 as an ARRAY part (I can't think of the name rn)
     END WHILE
     -- Now compare how close the available parts you get and set an attachment above the grid location and set the part like you did above, you have most of it and sorry most of this is in comments it is the best I can do in this time
     

No not minecraft pathfinding the red line yeah? “Baritone”. I want to recreate the red line waypoint to waypoint

Yeah that is essentially the same bar the coding language

There’s a service for pathfinding.

You should work around the tutorial here :slight_smile:

no that does not helppppppppppp