An alternative to built-in pathfinding?

So I’ve always had a game idea in the back of my mind - using custom characters in a small game environment and moving them around using roblox pathfinding service. A year or so ago I got very far in actually achieving this but I hit a brick wall when I realized Robloxs ‘new’ path-finding system had no way to stop jumping.

So, because I needed jumping to be absolutely impossible I opted to use the old, deprecated path-finding service that had no jump. But we hit an issue; it all looked well at first;

And I even had it working serverside (somewhat) smoothly:

But eventually I encountered a big issue, my characters cannot even sheer the smallest of objects. And I tried multiple different ways such as wedges. Nothing works. (shown in images below, source code included.) Does anyone have an idea of how to resolve this?

My admittedly, very old and inefficient script: https://pastebin.com/raw/RRwyBfKy

I have partly resolved this issue by making the roads larger, and with no height difference.


This new system of using nodes seems to work well

How does this relate with the category “Public Portfolios,” this category is meant to be used to present your work and have people hire you.

moved, it was cause I clicked ‘Continue Draft’ whilst in the scripting section.
It also moved me to the previously viewed board.

2 Likes

Can you create an invisible roof that the new pathfinding service will detect and eliminate jumping possibilities or making tall invisible walls?

If you need custom pathfinding behaviour then it might be worth considering making your own pathfinding system. The easiest way to achieve this is to use a set of parts called nodes which an agent (the thing which will move around) can move between. You will have to consider how you want to do this but the two most common (simple) ways are either creating a 2d grid (like a chess board) or by using waypoints. (the most common is using navigation meshes but they are quite complicated especially in roblox).

Once you have your nodes you can then find the shortest path from one to another by using a pathfinding algorithm. Now there are a fair few but the best one to start with is called A* as it is reasonably simple and provides very good performance. Here is an explanatory video https://www.youtube.com/watch?v=aKYlikFAV4k as well as some pseudocode of how to implement the algorithm A* search algorithm - Wikipedia.

Do take careful consideration into whether you want your pathfinding to be dynamic (adapts to changes in the environment) or static (remains the same regardless of the environment). Dynamic pathfinding is significantly harder and is one of the best reasons to use roblox’s pathfinding api.

Even if you don’t end up using this in a project, doing this kind of exercise is a very good way to improve your coding ability (as you need to consider your data structures) but is also a fun exploration into a potentially new area of math. This type of problem occurs very often in mathematics (and by extension computer science) as we often want to traverse graphs (collections of nodes). This comes up so often as many of our data structures can be represented by graphs and traversals/searches are what we want to do most of the time.

Perhaps the easiest way to see how helpful and powerful this is would be to consider a state based ai. We can create a tree (special type of graph) of all the possible states the ai can transition to. We can then use a search algorithm (like A*) to find the optimal path through this tree so the ai achieves a victory. By doing this you don’t have to come up with clever strategies of how the ai should work and the ai will be able to always choose the most optimal set of moves.

I feel like I’ve gone on for a bit too long now but you get the idea. Pathfinding is very satisfying when you get it working and I hope you manage to get there! Feel free to ask me any questions you have along the way. Good luck!

6 Likes