regenerate new path
thoqex opened this issue · 1 comments
hi yonaba,
thanks for the library you created. but i have a question about my TD project.
can we just regenerate new path after we change the value of grid map? in example, i have a listener so i can change the value of grid map from walkable into not walkable. so when the program start and it had a endPoint. player can adding some block so we need a new path to go through the end point.
thanks
Hi @thoqex,
No problem, indeed you can.
When you send a request to getPath, it starts looking for a path from the given start node to the given end node. During this search, it evaluates on the fly the actual state of any node which is being processed : in case this node is no longer walkable, it won't consider it. otherwise, this node will be considered in the actual search.
So basically, the workflow would be the following
- Creating and setting the grid map (only once)
- Perform path requests calling
pathfinder:getPath(...)
- changing some node walkability (eventually), then goto step 2 again.
Sorry for the delay, though.