Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D Pathfinding Demos or Documentations? #213

Open
evandarcy opened this issue Jul 18, 2023 · 3 comments
Open

3D Pathfinding Demos or Documentations? #213

evandarcy opened this issue Jul 18, 2023 · 3 comments

Comments

@evandarcy
Copy link

Hey @schteppe, I am really curious about your fork.

At the moment this is the approach I am taking:

var grid = new Grid(gridWidth, gridHeight);
grid.setWalkableAt(x, y, true); // Set player position as walkable
var path = finder.findPath(startX, startY, endX, endY, grid);

I would like to extend this code to work in a 3D environment, how could I use your fork to achieve something like this? Are there some extra steps I would need to take?

If there are any demos or documentation specific to your fork, I would love to see them!

Thank you!

@brean
Copy link

brean commented Aug 13, 2023

Hey @evandarcy ,
What do you mean with 3D-environment? Flying vehicles? That's possible but it would require you to implement a different form of grid (with a 3rd z-value), the algorithms itself work on any graph.
If you just want to use 3D environment but 2D pathfinder (e.g. using THREE.js) take a look at https://github.com/donmccurdy/three-pathfinding

@evandarcy
Copy link
Author

evandarcy commented Aug 16, 2023

Hey @brean,

Imagine you have 3D environment that takes the form of a multi-level building. On each floor of the building, there are different layouts of obstacles that are considered "non walkable" nodes. You will end up with multiple instances of the same (x,z) coordinates for each y level of the building that may have varying "walkable" or "non walkable" values for each coordinate.

I am wondering if the fork by @schteppe is intended for a scenario like that or should I be coming up with my own solution.

My concern with https://github.com/donmccurdy/three-pathfinding is that I would require the pathfinding to work in a procedural 3D environment, but maybe I could look at creating a navmesh using a tool like https://github.com/but0n/recastCLI.js

@brean
Copy link

brean commented Aug 17, 2023

hey evandarcy.

What you describe I would call multi-level path finding which would be less complex then real 3D where the agent could go in every direction (think of a quadcopter or an underwater vehicle navigating).
I implemented this multi-level approach in python for python-pathfinding a few weeks ago by having a "world" instead of one grid with multiple grids inside, instead of just one grid and then having "portals"(doors/elevators/steps/...) between the grids. It was actually very easy to implement (just a custom function that returns the neighbors):
https://github.com/brean/python-pathfinding/blob/main/pathfinding/core/world.py
(If you like to implement "stairs" with different distance-costs then for example "elevators" you would also need to implement a custom cost-function but I didn't do that in python-pathfinding).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants