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
338 stars 60 forks source link

Coming to v3 #35

Closed cortaninha closed 4 years ago

cortaninha commented 4 years ago

Hello thank you for your work. I've been using an old version but now moved to 3.01. Can you explain how to do the same functionality that existed with BlockCell and UnblockCell ?

I have been using those functions to make grid nodes walkable/non walkable in my game but in the new version these functions are not there. Only can find DisconnectNode. How to reconnect?

roy-t commented 4 years ago

Hey @cortaninha,

Ah you can use the GetNode function to get the nodes you want and then connect them again using Node.Connect. If you want more control you can also use all the nodes and edge classes.

cortaninha commented 4 years ago

Thank you for your quick response. One question about the Node.Connect, do i have to connect to all adjacent nodes for the pathing to work again for that node? I dont want to recalculate the grid every time some building is destroyed.

roy-t commented 4 years ago

Hey,

Yes you have to reconnect to all nodes that you would like a connection to (so all surrounding nodes).

I don't really understand "I don't want to recalculate the grid every time some building is destroyed." You can just create a helper function to connect it to all 'neighbors' for you. Its not an expensive operation.