Pathfinding service not working in a particular game

Pathfinding was working fine, but suddenly out of nowhere it stopped working.

The waypoint table that is returned is always completely empty.
https://gyazo.com/2607a996a6dc64a7862a06039aab469e

Code:

local destination = workspace.Dest.Position
path = game:GetService("PathfindingService"):CreatePath()
path:ComputeAsync(NPC:GetPrimaryPartCFrame().Position, destination)
print(path:GetWaypoints())

It does not work at all, this is really frustrating.
I tried using raw coordinates in various positions but it never works.

It works fine in other games, but this particular game seems to be failing.

1 Like

That’s because you never did anything with the path. All you’ve done so far is given the computer a map but not told it do anything, you’ll have to use some sort of loop (preferably a pairs or equivalent) to go through all of the entries within the waypoints and move the NPC accordingly.

It does not return coordinates. You can see in the footage that the waypoint table it returns is completely empty. My point here is that the service isn’t working not the NPC movement.

Can you print out the path status after computing it? Maybe it will give you a better idea of the problem:

path = game:GetService("PathfindingService"):CreatePath()
print(path.Status)

If it’s created the path correctly it should output Enum.PathStatus.Success

It returns Enum.PathStatus.NoPath.

So it’s not making the path. By chance, do you have Terrain in your game? sometimes terrain can cause an issue with pathfinding. Another thing you can check is switching on Navigation Mesh in Studio (File → Studio Settings) there’s a tick box for switching on Navigation Mesh close to the bottom. This will display the mesh over your map.

The game does have terrain, a lot in fact. What exactly am I supposed to look for with Navigation Mesh enabled?

If the cause is a terrain issue then the navigation mesh could be underneath the actual terrain instead of above it. If you check the PathFinding page you will see an image of what the Navigation Mesh should look like on your map:

When I had an issue with the terrain my NavigationMesh was being generated about 1000 studs below the terrain and was causing the NoPath error.

There’s not a single glimpse of it on this map.

Sounds like a similar issue to what I had - A rouge piece of terrain (probably a part of terrain that you deleted but missed a few pixels). Unfortunately there is no easy way of fixing it apart from searching and deleting all the little pieces (tedious and took a long time but did fix my pathfinding) or completely delete the terrain and re-do it.
Before taking drastic measures though I would copy/paste the map (without terrain) into a fresh baseplate just to see if pathfinding is working there - that would confirm it is the terrain issue that’s the problem.

1 Like

I will look into this, thank you for your help. I was about to go berserk

1 Like

Hi I have the same problem, Do you know how to change the navigational path?

I couldn’t get a navigational area to show up on the game I’m working on, so I decided to take a different route other than pathfinding.

To show navigational go to the studio settings and turn on “Show Navigational Meshes”

Yes, there is none although the I have the option selected.

I made a post about it, there is, check it out!

The problem is there was no navigational mesh in the game. When I had the option selected, there would be no mesh visible at all. My team has managed to fix it, so it is no longer an issue.

I’ve been working with paths for a long time, and in case you or someone else is reading this, know that this problem is something difficult to understand, place details can make your path not work, so what I recommend is that you leave your computePath in a loop, and then open the server, and delete everything, until you find the instance that is causing the problem

1 Like