We use cookies on this site to enhance your user experience

PathfindingService

PathfindingService

PathfindingService is used to find a path between two points. The paths that the service finds are meant for regular sized Roblox characters. The paths make sure the characters can move between the points without running into walls or other obstacles. Paths will not only show where a character needs to walk to reach their goal, but will also show if the character will need to jump to get over gaps. Paths can be used both for characters controlled by players and for non-player characters.

PathfindingService generates a navigation mesh over all of the parts in the place while a game is running. This mesh indicates where a regular sized character can walk. Any path that is created with the service will stay within the mesh. If the geometry of the place changes, for example if a part moves or is created, then the navigation mesh will be recaulculated.

To see the navigation mesh for a place, open the place in Studio, navigate to File > Settings, and toggle on the setting Show Navigation Mesh. The mesh will then show up in the 3D view. The purple areas in the place show where a character can walk. The areas that are not colored in are considered blocked for characters. Studio also displays arrows on top of the mesh. These show where a character would have to jump in order to get from one part of the mesh to another.

Navigation Mesh

PathfindingService has one function called FindPathAsync which is used to find paths. This function takes two parameters: the starting point of the path and the end point. This function then returns a Path object.