pathfun: a pure Lua library for 2D pathfinding, with editor

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
darkfrei
Party member
Posts: 1169
Joined: Sat Feb 08, 2020 11:09 pm

Re: pathfun: a pure Lua library for 2D pathfinding, with editor

Post by darkfrei »

How to make this metapolygons, where you connect multiple polygons together?
2023-01-05T15_43_47.png
2023-01-05T15_43_47.png (167.02 KiB) Viewed 4559 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
apicici
Prole
Posts: 23
Joined: Wed Dec 18, 2019 9:25 pm

Re: pathfun: a pure Lua library for 2D pathfinding, with editor

Post by apicici »

darkfrei wrote: Thu Jan 05, 2023 2:47 pm How to make this metapolygons, where you connect multiple polygons together?
You can use the visual editor to easily create something like that, or just create the polygon map by hand by creating a table containing all the inner polygons. The polygon map passed to the library can contain any number of convex polygons, and they are allowed to be disjoint. You only need to use multiple polygon maps if you are planning to dynamically turn on/off some of them.
zingo
Prole
Posts: 42
Joined: Mon Jan 16, 2023 7:34 am

Re: pathfun: a pure Lua library for 2D pathfinding, with editor

Post by zingo »

Thank you for sharing this! Just...wish I had a better grasp of how the whole thing actually works...

A few questions if you don't mind :

1: Are the paths calculated using some sort of "bounding box" for each point, or just the "x,y" coordinants?
2: Is there a way to update each path more in "real time", so that the points can "chase" or "follow" a constantly moving target?
3: Aside from integrating this with some sort of physics library (or just Box2d) and having a "priority queue" or something, any suggestions for how one would go about getting the points to move around each other as well (like "herds"), or would that simply be too complicated?

Again, thank you! I haven't come across many polygon based pathfinding libraries, so this is just what I was looking for. It's also a lot of fun watching all those little dots move about various polygon maps.
apicici
Prole
Posts: 23
Joined: Wed Dec 18, 2019 9:25 pm

Re: pathfun: a pure Lua library for 2D pathfinding, with editor

Post by apicici »

zingo wrote: Mon Jan 16, 2023 10:55 am 1: Are the paths calculated using some sort of "bounding box" for each point, or just the "x,y" coordinants?
2: Is there a way to update each path more in "real time", so that the points can "chase" or "follow" a constantly moving target?
3: Aside from integrating this with some sort of physics library (or just Box2d) and having a "priority queue" or something, any suggestions for how one would go about getting the points to move around each other as well (like "herds"), or would that simply be too complicated?
  1. the paths are calculated by first finding the "shortest" polygonal path between two points, that is a sequence of polygons, each sharing an edge with the next one, with the first polygon containing the starting point and the last polygon containing the target. Shortest here is with respect to the sum of the distances between the centroid of each polygon and the next one.
  2. You can simply rerun the algorithm at each update by using the current position as the starting point and the position of the moving point as the target.
  3. I'm not sure what moving around each other means here. Is there a fixed point that another point should move randomly around, constrained within the polygon map, or are both points moving?
zingo
Prole
Posts: 42
Joined: Mon Jan 16, 2023 7:34 am

Re: pathfun: a pure Lua library for 2D pathfinding, with editor

Post by zingo »

Thanks for the reply. What I mean by "move around each other" is that each point (or entity) would avoid "colliding" with another as they all navigate towards the target (rather than simply overlap or "bottleneck", as they do now)...sort of like units would in the classic Warcraft...(if that makes sense).
apicici
Prole
Posts: 23
Joined: Wed Dec 18, 2019 9:25 pm

Re: pathfun: a pure Lua library for 2D pathfinding, with editor

Post by apicici »

I suspect that kind of thing is best achieved with a different kind of navigation system. Pathfun is not really designed to deal with movable obstacles in its current form.
zingo
Prole
Posts: 42
Joined: Mon Jan 16, 2023 7:34 am

Re: pathfun: a pure Lua library for 2D pathfinding, with editor

Post by zingo »

Ah, that's okay. I may experiment with the points acting as "guides" for other entities that employ physics, so those could potentially "slide" around each other (provided the body shape is circular, and there's little or no friction), or simply have them form a "queue" until those closer to the target are out of the way...will have to see. In any case, Pathfun would be excellent for a "point n' click" game reminiscent of "Monkey Island" , "Space Quest", "Sam and Max", "Day of the Tentacle" etc. Had a blast playing those back in the day, and would love to see what people here come up using it, or anything you may be working on at the moment.
apicici
Prole
Posts: 23
Joined: Wed Dec 18, 2019 9:25 pm

Re: pathfun: a pure Lua library for 2D pathfinding, with editor

Post by apicici »

Indeed, pathfun is a standalone part of my LÖVE point and click adventure game engine (that I hope at some point will be in a releasable state) and I used in 2 such games so far :)
aleperry
Prole
Posts: 2
Joined: Thu Apr 20, 2023 8:46 am

Re: pathfun: a pure Lua library for 2D pathfinding, with editor

Post by aleperry »

Hi everyone! I would like to ask is it possible to have a version of the editor with a customizable reference system? So being able to change the position of the origin of the axis and perhaps the scale. This would help me a lot with conversions from monitor to game reference system and would drastically speed up small edits! Thank you <3
apicici
Prole
Posts: 23
Joined: Wed Dec 18, 2019 9:25 pm

Re: pathfun: a pure Lua library for 2D pathfinding, with editor

Post by apicici »

aleperry wrote: Thu Apr 20, 2023 8:56 am Hi everyone! I would like to ask is it possible to have a version of the editor with a customizable reference system? So being able to change the position of the origin of the axis and perhaps the scale. This would help me a lot with conversions from monitor to game reference system and would drastically speed up small edits! Thank you <3
That doesn't sound complicated, but I'm not sure I fully understand what you're after. Can you provide more information on how you're planning to do things? Do you need this in order to create the polygon maps starting from your game data?
Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests