tfe Homepage


Update on Threejs Path finding algorithm

Here is the article 18 about my series of posts about the game creation.

If you missed it, check out the previous part.

Game threejs on github

Path finding algorithm

Giving this first screen:

We first to detect on which cells are the start and end position.

Knowing the cells, we know if the 6 paths filling the hexagone are closed or opened, so we know were we can go from the start cell.

We are creating two variables: one with the visited cells, another one with the cells to visit.

Now we are using the first element of the "cells to visit". Same idea, we know which cells are connected to him:

So, we are adding the cell 4 in the 'to visit' list, but avoid adding again the cell 2, which is already in the queue.

And so on ...

Until a connected cell is the destination.

Sources and demo

The sources are now directly available on github.

I created the tag "blog-23" to be able to reach the state of the project corresponding to this blog post.

You can also test the demo of the latest state of the project.

A demo of the editor is also available.