Search Unity

Pathfinding in a network of waypoints

Discussion in 'Navigation' started by RickBerg, Apr 19, 2020.

  1. RickBerg

    RickBerg

    Joined:
    Jul 30, 2018
    Posts:
    1
    I am at the start of building a Farm Manager and for this I need a AI that is able to drive over a road (basic version in the image) using waypoints. It needs to find the shortest road and drive from waypoint to waypoint. I am trying to use BFS or A* but I have troubles implementing the algorithm. I understand that in a grid you can search for the neighboring tile and the distance to the endpoint, but how do you do this in a network as shown in the image? The way BFS and A* works is clear to me, but I can not seem to get the grid to work. How do you define the edges between the waypoints and calculate the distance to the endpoint for every single waypoint when there not in a grid?

    01.jpg
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi,
    You can find many implementations of A* at GitHub, just do a few searches. I wouldn't "waste" precious time unless you intend to understand how A* actually works.
     
  3. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    359
    Hi,

    use abstraction layer, implement simplest Dijkstra algorithm and move on. Make revision when you will get to hiccups.
    Prototyping and iterative development is the way to go
     
  4. mostafanastary

    mostafanastary

    Joined:
    Oct 4, 2015
    Posts:
    31
    Hi, are you find answer for your problem?