• Advertisement
Sign in to follow this  

Pathfinding noob, nodes instead of tiles

This topic is 2899 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Im using pathfinding code i found on the net (A*). And i understand most of it. Its based on tiles so each tile connects automatically to each 8 tiles around it. In my new game i need to add nodes manually on the map and let my actors (ships on ocean moving between ports) pathfind these nodes to travel correctly. How would this work? My idea is to have all nodes check for suitable "neibours" beforehand and store this. The patherclass has functions like AdjacentCost, findPath etc. So you think i could modify the old tilebased class into something that works with arbitrary positioned nodes or does that work completely different? Thanks E

Share this post


Link to post
Share on other sites
Advertisement
The A* algorithm isnt exclusive to tiles, it is actually a graph search algorithm, tile based a* just treats each tile as a node with 4 (or 8) connections to neighbour nodes. You could use any arbitrary number of nodes or layout of the nodes, you could use any mesh (essentially a 2d graph) where the mesh represents the sea (or seaways) and some nodes are ports. The ship could sail to the nearest node and run A* to find its way to port.

Share this post


Link to post
Share on other sites
Also, the nodes in the graph that you search with A* don't have to correspond to points in your world; they can also correspond to regions. Then the edges of your graph just encode which regions are adjacent. This is the basic idea behind the popular navmesh concept.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement