Can I make PathfindingService use nodes I already created?

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

  1. What do you want to achieve? Keep it simple and clear!
    I have nodes already defined and I want the PathfindingService to use those nodes instead of the ones created by it. That is, use the nodes and find the path necessary to the desired end point. Is there a way to do this? Does there exist something that I missed or is that not within PathfindingService?

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Just my own I came up with, mainly concepts at the moment. They seem more complex than necessary, however, so I want to know first if I’m missing something before going through with it.

You could use for-loop through each node and calculate the path with PathfindingService?

Edit: If you already have the nodes, you could just for-loop through the nodes and use Humanoid:MoveTo to move the humanoid.

The PathfindingService’s use is to make those nodes. It doesn’t do anything with actually moving the character model.

There are many nodes, though. It would have to be able to select one somehow. On a predefined grid, for example, with many nodes defined in all directions, looping through wouldn’t exactly work. I also need all of those nodes to exist as well.

Edit: I figured the PathfindingService would have that handled.

1 Like

PathfindingService creates its own nodes. If you must use your own nodes, you could try grouping specific nodes together for predetermined paths.

Edit: Wording.

I would still need an algorithm to figure out which to group together, might as well create my own pathing then. So PathfindingService cannot use predefined nodes? Just the ones it creates for itself?

Edit: Or use a method to gather information around for those nodes and then connect them until it reaches the destination?

As far as I know, and have seen on the Developer Hub, PathfindingService doesn’t use predefined nodes because its purpose is to create them.

1 Like

All right, excellent. Good to know where to go from here now, thank you.

1 Like

You might want to look in Dijakstra’s Algorithm or A* Algorithm to find the shortest path from a set of nodes from the start to finish. When I made my custom pathfinding (I had my own nodes) I used Dijakstra’s algorithm to find the shortest route from the start to destination. You might want to use A* though as it is generally quicker, depending on which heuristic you use.


More info on Dijakstra: Dijkstra's algorithm - Wikipedia
Video by Computerphile on how Dijakstra works: https://www.youtube.com/watch?v=GazC3A4OQTE
More info on A*: A* search algorithm - Wikipedia

2 Likes

Yea, I was looking into doing that but my circumstances may be different, assuming my method works. Definitely worth a read into Dijakstra’s algorithm, haven’t seen that one yet.