Does pathfinding suck, or do I suck?

I’m trying to use PathfindingService but for whatever reason the Status is returning NoPath although there is a clear path that I can see. I’m trying to create a (somewhat) efficient party-pathfinding system with proper offsets behind and to the right (or left) of the player depending on the party layout.

Now, here’s the issue. I’m trying to use Path:GetWaypoints()[1] on a loop since I can’t exactly use raycasting due to what I mentioned earlier, there is no dummy part to signify where the NPCs are supposed to go, therefore there’s no way for the raycast to be used to check if there is something blocking the NPC’s access to the character.

It sounds pretty foolproof since all of this work is being done on the Client so there’s no delay from the server or anything of the sort, however, for some reason under any circumstance the path will return Enum.PathStatus.NoPath. Every. Single. Time.

I tried even using a displacement of (0,0,16) so there’s no factor that required jumping or anything of the sort, but I still got this:


Yep, you guessed it, Enum.PathStatus.NoPath.

The warns are from another part of my script that warns me whenever a path isn’t able to be found, which is having the same issue (the whole script that controls the party and does the pathfinding.)

Any help?

My source is here:

local newPath = game:GetService('PathfindingService'):CreatePath({AgentCanJump = true, AgentHeight = Character:WaitForChild("Humanoid").HipHeight, AgentRadius = 3});

while wait() do
	if (not _G.DisablePartyMovement) then
		local e, s = pcall(function()
			for i, v in ipairs(workspace.OverworldMembers:GetChildren()) do
				local hum = v:FindFirstChild("Humanoid")
				v.Humanoid.WalkSpeed = Character.Humanoid.WalkSpeed
				--if not (isPartyInSafePlace) then break end;
				local CharCF = Character.PrimaryPart.CFrame
				local ofst;
				if (i == 1) then
					ofst = CharCF.RightVector * - 4
					ofst = ofst + CharCF.LookVector * -3
				else
					ofst = CharCF.RightVector * (i * 3)
					ofst = ofst + CharCF.LookVector * -3
				end
				local CharPos = CharCF.Position + ofst
				newPath:ComputeAsync(v.PrimaryPart.Position, Vector3.new(CharPos.X, v.PrimaryPart.Position.Y, CharPos.Z))
				if (newPath.Status == Enum.PathStatus.Success) then
					if (isSafeToMoveTo(CharPos)) then
						--v.Humanoid:MoveTo(CharPos)
						warn'ya'
						v.Humanoid:MoveTo(newPath:GetWaypoints()[1].Position)
					else
						warn'no'
						v.Humanoid:MoveTo(v.PrimaryPart.Position)
					end
				else
					warn(newPath.Status)
					v.Humanoid:MoveTo(v.PrimaryPart.Position)
					placePartyInSafeArea(workspace.OverworldMembers:GetChildren(), workspace.SceneContainer:WaitForChild('Scene'))
				end
				
			end
		end)
		local x = not e and warn(s)
	end
end

Edit @ 4/7/20 11:31 - I also tried running this:

local mpath = game:GetService("PathfindingService"):CreatePath(); 
mpath:ComputeAsync(workspace.Fifkee.PrimaryPart.Position, workspace.Fifkee.PrimaryPart.Position); 
print(mpath.Status)

…and it returned Enum.PathStatus.NoPath. How fun.

Now, here’s the very weird part. I tried running the same piece of code in the command line but added Vector3.new(0,0,4) to the ending position. I tried it on the main game, and then ran it on an empty baseplate. The main game returns NoPath, but the baseplate returns Success.

Pathfinding Service is characteristically unreliable when it comes to traversing complex structures or a majority of terrain formations. I’d recommend testing this script using a flat path and seeing if it produces the same results.

If it works on a flat path, perhaps attempting to have smaller paths connected to reach the destination would be more beneficial in this situation.

2 Likes

It’s all on a flat path, as I don’t really intend to use any form of complex structure (maybe a bit of unions, but they usually aren’t composed of curved paths or anything).

My game is just a testing baseplate: