Understanding Dijkstra Application

Hi All,
I’m currently working on making a tactical RPG type of game and need to have the possible tiles that a character can move to be highlighted and only allow movement to those tiles. It would also need to move the character to the destination after a button press.
I’ve been scouring unityanswers and every other page I can find to understand how to do this. I’ve found a ton of different uses of the algorithm and a few for my specific use but I’d really like to understand whats going on with it. I understand a little about Lists and I know all the unity basics so far but I don’t understand whats going on with the actual scripts themselves.

Here’s a few examples of what I’d like to happen:

Dijkstra's Algorithm (UNITY3D) - YouTube

I’ve found some sample code thats pathfinding (not quite the same thing) with Dijkstra:

If anybody can either help me understand how this is supposed to work or can find a step by step explanation of how this works I’d really appreciate it.


Here are some in depth explanations about some path finding algorithms, including Dijkstra and A*


These might be of help as well



There is some animations here.

Dijkstra is an algorithm for any graph, it’s not just video game pathfinding. You’ll need to understand a little what is graph theory.

To apply Dijskra: you need to set all nodes (a tile here) and all edges (the path between nodes in our case) and to have for each edges a cost (the distance for example or the “difficulty”) and 2 nodes. These nodes are neighbours.

When you are looking for a path, you actually check all neighbour of your current position, discard “too expensive” path move your current position to the next position and repeat until you reach your destination.

All the difficulty of Dijskra’s algorithm is to understand how to discard too expensive path.

Another article from AI Game Dev