Algorithm for waypoint path following?

Posted by Thierry Savard Saucier on Game Development See other posts from Game Development or by Thierry Savard Saucier
Published on 2014-08-20T23:15:29Z Indexed on 2014/08/21 10:31 UTC
Read the original article Hit count: 354

Filed under:

I have a worldmap, with different cities on it. The player can choose a city from a menu, or click on an available cities on the world map, and the toon should walk over there.

I want him to follow a predefined path.

cities

Lets say our hero is on the city 1. He clicks on city 4. I want him to follow the path to city 2 and from there to city 4.

I was handling this easily with arrow movement (left right top bottom) since its a single check.

Now I'm not sure how I should do this. Should I loop threw each possible path and check which one leads me to D the fastest ... and if I do how do I avoid running in circle forever with cities 1-5-2 ?

© Game Development or respective owner

Related posts about path-finding