This is a devlog about the pathfinding in Graal Seeker. In this article I will show you some animated gif with wip animations. I would to apologize in advance for the poor quality of the gif, you should know as well that it's only 10 fps. Furthermore, you will see green and red dots I use for test purpose. The green dots show the path and the red dots show the not walkable tiles. Anyway, it's been a long time since I showed you some animations so I hope you like it.
But first, how the pathfinding works here? It's a basic A Star pathfinding that excludes not walkable tiles. We store all tiles of the path in the correct order. We calculate the vector between the current position and the very next tile and calculate a movement step with which the movement engine will move the character at each frame.
Now, let's see the current state for the implementation of the z-ordering. Every time a character reaches a tile, the z-order list is updated. You can see the character walk behind and ahead the trunk.
Then, during a movement the player can change his mind and request for an other destination. To have something smooth and to keep the characters aligned with the centers of the tiles, we only update the destination when the player clicks, and we wait the character reaches the next tile before recalculating the path. This is why we don't calculate the vector and the movement step with the destination tile, and we use the next tile instead. Here, you can see the path change each time I click.
Finally, we can't let the characters go at the same destination. So, we recalculate all paths at each frame. We always set the next tile of the movement as not walkable. You can see here a character interrupt the movement of an other character.
Thanks for reading :) Next time, I will present you some characters of Graal Seeker.