Page 1 of 1

How do I use a pathfinding system?

Posted: Thu Mar 12, 2020 10:29 pm
by Leonardo2450
I'm developing a project and I need my enemies to know how to recognize the best path to the player (pathfinding). I come to you to ask: How do they work internally? Is there one available for a game made without a gang?

Re: How do I use a pathfinding system?

Posted: Fri Mar 13, 2020 12:19 am
by Varkas
Most systems work on graph structures (nodes and links). The graph is built from the map (walkable ways) and then searched for the shortest path between two nodes.

There surely are some readymade systems, but it will depend on your map representation which of them fits.

Re: How do I use a pathfinding system?

Posted: Sat Mar 14, 2020 6:03 pm
by tobiasvl
Leonardo2450 wrote: Thu Mar 12, 2020 10:29 pm I'm developing a project and I need my enemies to know how to recognize the best path to the player (pathfinding). I come to you to ask: How do they work internally? Is there one available for a game made without a gang?
What do you mean by "gang" in this context?

If you want to know how these kind of path finding algorithms work, read up on graph theory and graph traversal algorithms. A common one in games is A*: https://en.wikipedia.org/wiki/A*_search_algorithm

Here's a simple library for A*, which is a path finding algorithm. All it needs you to do is implement a callback function where you decide if a specific map cell is walkable or not, and then it does the rest. https://github.com/wesleywerner/lua-star

There's also this one, which is a bit more involved; you have to make a collision map, a two-dimensional table, that acts as a mask for defining walkable cells. https://github.com/Yonaba/Jumper

Re: How do I use a pathfinding system?

Posted: Mon Mar 16, 2020 1:15 pm
by dusoft
Jumper is really cool, I can recommend it.