roy-t / AStar

A fast 2D path finding library based on the A* algorithm. Works with both grids and graphs. Supports any .NET variant that supports .NETStandard 2.0 or higher. This library has no external dependencies. The library is licensed under the MIT license.
http://roy-t.nl
MIT License
340 stars 60 forks source link

Question #45

Closed MAYasin closed 3 years ago

MAYasin commented 3 years ago

Just a question, would like to know how to convert the edges to a position like a coordinate system (X, Y). I am working on a game that uses angles as a direction (the map is like a graph) that my player uses to move. Having the position of the edges would be really helpful. Should I create more nodes to store my obstacles? Sample code usage of this library would be really helpful.

roy-t commented 3 years ago

Hey MAYasin,

I'm not sure if I follow. Each node has a position property which gives the position of the node. Or are you using the Grid class to generate a grid of connected nodes? In that case you should map the 'abstract' location of a node (for example {1, 1}) to a physical location like, New York or {1254.42f, 41.2f} in your own code using a mapping function.

Alternatively you can also generate the nodes yourself so you can use the position property.

You can take a look at the viewer or the tests if you want more sample code to study the library.

Does that help? (Closing for now, please re-open if you have more questions)