Skip to content

do420/Unity-AStar-Pathfinding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnityAStarPathfinding

Shortest path finding with A* algorithm for Unity.

Ekran Görüntüsü (21) Ekran Görüntüsü (22)

Usage (On example 3D human mesh)

List<Node> nodes = new List<Node>(); //create nodes list to store nodes on the scene
List<Edge> edges = new List<Edge>();  //create edges list to store edges on the scene 
// follows basic (NODE - EDGE - NODE) structure

 for (int i = 0; i < vertices.Length; i++) //add vertices to the nodes list
 {
     Vector3 point = transform.TransformPoint(vertices[i]);
     var node = new Node(point, i);
     this.nodes.Add(node);
 }

//add connections between vertices to the edges list
//...
//...
//...

//Use PathFinder3000's method to find the path.
PathFinder3000.Search(this.ALL_NODES[vertexIndex1], this.ALL_NODES[vertexIndex2]);
// (startingNode, destinationNode) as parameters.

//Visualize the path using a line renderer:
ShowThePath(PathFinder3000.Search(this.ALL_NODES[vertexIndex1], this.ALL_NODES[vertexIndex2]));

More information about the A* Algorithm:

https://en.wikipedia.org/wiki/A*_search_algorithm

About

Shortest path finding with A* algorithm for Unity.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published