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: 15
Joined: Wed Jul 17, 2019 12:45 am
Location: Esta xd

How do I use a pathfinding system?

Post 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?
-Leonardo2450-
[DATA EXPUNGED] Argentinian looking for something to do in his spare time. :awesome:
User avatar
Varkas
Citizen
Posts: 83
Joined: Mon Mar 09, 2020 2:26 pm

Re: How do I use a pathfinding system?

Post 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.
In soviet russia, code debugs you.
tobiasvl
Prole
Posts: 29
Joined: Mon Oct 01, 2018 4:58 pm
Location: Norway
Contact:

Re: How do I use a pathfinding system?

Post 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
User avatar
dusoft
Party member
Posts: 492
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: How do I use a pathfinding system?

Post by dusoft »

Jumper is really cool, I can recommend it.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 58 guests