# Unity Navigation & Pathfinding and A star algorithm

I just tried to follow a tough tutorial about A* path finding in Unity C#. I have also tried Unity own Navigation & Pathfinding system which is actually quite easy to understand and implement. I am willing to know it that how NavMesh system of unity actually works. Do it also implement the A* algorithm. Further I want to ask that how does A* algorith will work with slope. I implement A* with plane where is no slope.

Here is how a computer will see an a star path find: As you see, it is just a graph of nodes with certain neighbors. Between each neighbor, there is a "distance", or weight, that connects the two nodes. The algorithm finds a rout between nodes that will have, when all of the path lengths are added up, the smallest possible number.

If you look at a navmesh, all it does is separate the map into a lot of triangles. Every touching triangle represents a neighbor, and the dist between the two neighbors is most likely the distance between each triangle's center point, but there might be other algorithms. And, using this graph, it probably uses a star, maybe with performance optimizations. See here for more info.

On a grid, like the ones you saw in the video, the nodes are the tiles, and the distance is just 1 unit for adjacent and about 1.4 units for diagonal.

Going back to your slope, if you want the agent to be slower on it, then artificially make the number between the nodes larger like:

if (nieghbor has to much of a y-value difference):
neighbor_cost *= 5