Route by adampassey - 2

Games & ProjectsAI

Simple weighted graph pathfinding package for Unity

Unity 2018.3.9f1Unknown LicenseUpdated 79 days agoCreated on May 23rd, 2016
Go to source

Route

Simple weighted graph pathfinding package for Unity3d.

Usage

Download or clone the Route repository locally and import route.unitypackage by selecting Assets -> Import Package -> Custom Package. Drop a Route Grid object into your scene and press the Build Grid button. This will generate a graph that can be used to route the shortest path from one node to another.

Once you’ve created your node grid, your can find the shortest path between two nodes using Router.cs:

using Route;

void ExampleMethod() {
  Router router = new  Router();
  RouteResult result = router.Route(startNode, endNode);

  //  shows the total cost of this route
  Debug.Log(result.cost);

  //  print every node in this path
  foreach (Node n in result.nodes) {
    Debug.Log(n.gameObject.name);
  }
}

alt tag

Show all projects by adampassey