Feedback on PathfindingService, Character Pathfinding pages in the API, Regarding COSTS

While these two pages do a decent job of informing the user on how to use PathfindingService, they don’t tell you whatsoever what the upper limit to a Pathfinding Cost is.

Sometimes I’m trying to create a pathfinding modifier where an NPC will try extremely hard to avoid an area, but will ultimately pass through it if there is no other solution. I don’t know how to assign a proper cost to this modifier, as I don’t know what the maximum cost of a path is, and it isn’t listed anywhere on the documentation.

Page URL: https://create.roblox.com/docs/reference/engine/classes/PathfindingService
Page URL 2: https://create.roblox.com/docs/characters/pathfinding

math.huge would make it non-traversable no matter what, sure, but what if I want it to be traversable just as a last resort?

For example, the unit will generally try to entirely avoid pathfinding through the orange brick, but if ultimately that is the ONLY WAY to get to the green brick, it’ll go through it.

Also, how do paths give up and stop computing based on costs?

If I have a situation like this where the orange area is extremely high cost. Assuming I’m using partial paths, at what point will it wander towards the green brick before the cost of the path in total is too high? Is there an upper limit to the cost of a path?

The cost system is super vague and not explained very much, which makes it hard to finetune costs.

2 Likes

math.huge marks a modifier or material as non-traversable.

Materials: https://create.roblox.com/docs/characters/pathfinding#set-material-costs

All materials have a default cost of 1 and any material can be defined as non-traversable by setting its value to math.huge.

Modifiers: https://create.roblox.com/docs/characters/pathfinding#work-with-regions

A modifier can be defined as non-traversable by setting its value to math.huge.

Not what I’m asking though.

math.huge would make it non-traversable no matter what, sure, but what if I want it to be traversable just as a last resort?

For example, the unit will generally try to entirely avoid pathfinding through the orange brick, but if ultimately that is the ONLY WAY to get to the green brick, it’ll go through it.

Also, how do paths give up and stop computing based on costs?

If I have a situation like this where the orange area is extremely high cost. Assuming I’m using partial paths, at what point will it wander towards the green brick before the cost of the path in total is too high? Is there an upper limit to the cost of a path?

The cost system is super vague and not explained very much, which makes it hard to finetune costs.

1 Like

Ah, you should update your post to make that clearer.

You can accomplish this by just setting a reasonably high cost to the last resort path.
If you want an exact limit, it appears to be 3.4028235677973362e+38 (the maximum double that rounds down to the maximum representable float), any number larger than this marks the region as non-traversable.

Pathfinding will always attempt to find a complete path to the goal, if it can’t find one, then it’ll find the best partial path.

Perhaps an example showing how to make a “last resort” path could be added, showing that you can set a decently high cost to accomplish that.

2 Likes

Pathfinding will always attempt to find a complete path to the goal, if it can’t find one, then it’ll find the best partial path.

Right, but at what point does it give up? Do paths have a finite limit for a total traversal cost? (Eg, the cost of the entire path cannot exceed 2000).

You can accomplish this by just setting a reasonably high cost to the last resort path.
If you want an exact limit, it appears to be 3.4028235677973362e+38 (the maximum double that rounds down to the maximum representable float), any number larger than this marks the region as non-traversable.

From some of my use cases, NPCs would refuse to pathfind in an area with a cost of 250. I don’t know why that is, since technically its traversable, just expensive. This is sorta why im asking for more clear documentation about this sort of thing.

Hi @sicknoobie ,
Apologies for the epic time it took me to address this. I’ve updated the Pathfinding guide with some more details which hopefully help:

Take care,
IgnisRBX

Hi there! Thank you very much for clarifying some limitations. I do have a few other questions though.

I was told that ComputeAsync() requests would try to time out after a certain Computation Time when UseImprovedSearch is enabled, I was unaware there was a node limit. So my question is, is there an actual hard-capped time-limit for computation requests, or is it just the node limit?

My followup question, what defines a node? Is there a way to see the total amount of nodes used for a path, or otherwise visualize them? Would changing waypoint parameters affect this (Eg, would AgentParemeters with WaypointSpacing of 300 use less nodes than AgentParameters with a WaypointSpacing of 10?)

Do pathfinding costs effect nodes at all either? Like, do paths have a max combined cost of all the waypoints? Or does that not matter?