i am trying to make a pathfinding NPC and so far, it has been going well and the NPC functions correctly. however i would like to implement one feature for the NPC.
say there is a road and there is a sidewalk, the road is made of the slate material and the sidewalk concrete. How do i make the NPC pathfinding prefer creating the path over the sidewalk instead of the road?
The ComputeAsync page(Path | Roblox Creator Documentation) Code Sample includes an agentParams table with a key that specifies MaterialWeights for the agent, which should solve your described issue if you’re using roblox pathfinding. You can just assign higher weights to materials that are not preferred.
I say “should” because they only document AgentRadius,AgentHeight, and AgentCanJump as params; literally the only place these additional parameters are mentioned is in this code sample (that i could find.) So whether or not they work is up for you to experiment with, although they probably do work.
If you’re doing a custom pathfinding implementation, implementing something based on Djikstra’s Algorithm would be your best bet, as you can weight preferred material nodes at lower values.
Wait, really? I’m currently creating a pathfinding module to make Pathfinding a simple process to code in to any project but also be flexible enough to allow for some customization. I’ve never heard of this property before however, despite all the research I’ve done. I probally should have looked at the code samples. Thank you very much for this! Do you know what each of the values signifies and how it’s value affects the outcome?
It’s worth mentioning that I’ve talked to some other developers after posting and a few have suggested that these properties may not actually work.
That being said, if they DID work, the weighting system would ideally be similar to Djikstra; pathfinding “nodes” would be given a “material” based on what occupied said node/voxel, same for tagged collections assumedly. Based on the weight params provided, it would adjust each node and then calculate a path of shortest weight.
This is complete speculation, there is genuinely no way to know how they actually calculate it unless they tell us. It would just make the most sense if it worked similar to Djikstra
Do you know when these were added? Sorry, if I’m asking too much, but I never saw an update to the developer roadmap that mentioned pathfinding, even though a Roblox engineer stated that they would add it as a goal this year.
No, sorry. The only knowledge I have is that they exist in that single code snippet with zero context.