How do I use a pathfinding system?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Leonardo2450
Prole
Posts: 13
Joined: Wed Jul 17, 2019 12:45 am
Location: Esta xd

How do I use a pathfinding system?

Post by Leonardo2450 » 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?
-Leonardo2450-
[DATA EXPUNGED] Argentinian looking for something to do in his spare time. :awesome:

User avatar
Varkas
Citizen
Posts: 54
Joined: Mon Mar 09, 2020 2:26 pm

Re: How do I use a pathfinding system?

Post by Varkas » Fri Mar 13, 2020 12:19 am

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.
In soviet russia, code debugs you.

tobiasvl
Prole
Posts: 23
Joined: Mon Oct 01, 2018 4:58 pm
Location: Norway
Contact:

Re: How do I use a pathfinding system?

Post by tobiasvl » Sat Mar 14, 2020 6:03 pm

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

dusoft
Party member
Posts: 104
Joined: Fri Nov 08, 2013 12:07 am

Re: How do I use a pathfinding system?

Post by dusoft » Mon Mar 16, 2020 1:15 pm

Jumper is really cool, I can recommend it.

Post Reply

Who is online

Users browsing this forum: bolesanahak, Google [Bot] and 19 guests