Pathfinding service don't work well

I try to make pathfiding system, it can set goals in order. (Sorry for my incomplete code)
However, the service don’t work well like attachment movie.

So, are there any ideas to solve this problem, and if you have any opinions about this issue, pls reply this forum. I appreciate your valuable replying!

◆Problem
NPC can’t move smoothly and often stop and face the wall (in addition, repeat jump)

◆Script

local Start = game.ReplicatedStorage["Seek"].chaseStart

local Humanoid = script.Parent.Humanoid
local Root = script.Parent:FindFirstChild("HumanoidRootPart")

local goal1 = game.Workspace["maze"]["Point"].Point1.Position
local goal2 = game.Workspace["maze"]["Point"].Point2.Position
local goal3 = game.Workspace["maze"]["Point"].Point3.Position
local goal4 = game.Workspace["maze"]["Point"].Point4.Position
local goal5 = game.Workspace["maze"]["Point"].Point5.Position
local goal6 = game.Workspace["maze"]["Point"].Point6.Position
local goal7 = game.Workspace["maze"]["Point"].Point7.Position



local goals = {
	goal1,
	goal2,
	goal3, 
	goal4, 
	goal5, 
	goal6,
	goal7
}

local path = PathfindingService:CreatePath()
local reachedConnection

Start.OnServerEvent:Connect(function(player)
	for i = 1, #goals do
		local success, errorMessage = pcall(function()
			path:ComputeAsync(Root.Position, goals[i])
		end)

		if success and path.Status == Enum.PathStatus.Success then
			print("success")
			local waypoints = path:GetWaypoints()	

			for v, waypoint in ipairs(waypoints) do	
				Humanoid:MoveTo(waypoint.Position)

				if waypoint.Action == Enum.PathWaypointAction.Jump then
					Humanoid.Jump = true
				end

				Humanoid.MoveToFinished:Wait()
			end
		end	

		if errorMessage then
			print ("error")
		end

		wait()
	end
end)```
2 Likes

I think part of it might be the lack of Agent Parameters defining the AgentRadius (essentially the character width), so the character hits corners as it walks past.
I don’t know what the spikes are toward the end of the video, but if they are traps that the char is supposed to jump over, then I wonder if it is trying to pathfind around them. Again, AgentRadius should fix that.

1 Like

robloxs pathfinding is literally the worst dog poo on the planet so you’ll have have to make a funky workaround like mentioned by @BadDad2004

1 Like

Thank you for replying.
Now I set AgentRadius to 1.5 and obstacles (including spikes) CanCollide set false. Then, pathfinding service performance quite improve previous but there is still one stop point. To solve this problem, all I can do is add goalpoints to the appropriate position?

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