I have ran into a problem. If I have an NPC that is chasing a player, if the player gets to a position where there is no path, even if the NPC can do it, the pathfinding service will not find a path to the player.
I’m specifically talking about jump power/jump height. On the NPC, it’s set to be able to jump up on top of a structure where the player is at, but for whatever reason, the pathfinding service is not taking that into account when computing a path to the player. It just gives me a NoPath error in the status.
The specific case in question is that the player can touch a powerup to increase their jump power (think gravity coil, but not a tool). Then the player can jump to the top of a structure that is 21 studs high. The NPC jump power is 100, which translates to a jump height of about 25.5 studs, more than enough.
This seems to be either a bug or an oversight but I do not have the ability to post in the bug reporting or the suggestions forum.
Default jumping humanoid pathfinding can only reach up to a maximum of 7 studs. If your building is taller than seven studs you have to use special pathfinding links. They are very easy to setup and you can control what actions a humanoid does.
With a pathfinding link however you need to be 100% confident that the NPC can jump/reach the end of the link.
So is that what the Enum.PathWaypointAction.Custom is for? I’ve been looking for how that is triggered, but so far all I’ve seen was walk and jump. I have some maps that the player uses jump pads and teleports to reach different areas. Obviously, I would need to have the NPC use those to get to those regions as well.
So what is this special pathfinding link that you speak of? I read about pathfinding modifiers, but I don’t really see how to use them in the manner that you are suggesting.
A Pathfinding modifier Is used to add, remove or modify certain areas of your pathfinding space.
A pathfinding link is used to connect pathfinding spaces to other pathfinding spaces and/or shortcut a pathfinding space.
A pathfinding modifier would be used for things like keeping off grass and staying on the path, walking through doors and keeping away or close to certain areas of the pathfinding space
A pathfinding link would be used for ladders, elevators or moving platforms that otherwise would not be able to be normally calculated with the default pathfinding algorithm.
Do you know how to make a pathfindable ladder using pathfinding links?
Well, I just tried it and it seems to work fairly well. There’s a couple of questions that I have about it though. A big jump I have already implemented, but what about teleporting? If a game has a lot of teleports, that list can be quite long. There needs to be a way to specify the target coordinates. I’m still testing this. I can find no documentation on the waypoints datatype. So I’m going to have to figure out what all is inside it myself.
Technically, you could add a CollectionService tag to the AI if it was teleported. And in the pathfinding code, if the teleport tag is detected, break the current waypoint loop and recalculate the path.
I did a print of the waypoint data and the coordinate of the next waypoint is included in the data along with the action and the label. So a teleport to those coordinates would be viable. I’m going to play with this some more and see what I can do.
Here’s what I have. I made three custom actions to deal with inaccessible places. They are as follows:
BigJump - Calculates the needed jump power based on the difference in Y coordinates, with a little extra for margin of error.
FallDown - Just uses Humanoid:MoveTo() to move off the edge of a place to fall down to the next coordinate.
Teleport - A true teleport which sets the position of the NPC to the waypoint coordinate while also doing Y + 4 to account for the height difference.
These three I imagine would be the most used. There is a forth one that I’m not sure how to do and that would be the jump pad. That I’m going to have to think about.
My understanding is that it tells the pathfinding service how high the NPC can jump so it can route them from point A to point B. It should be in the documentation.