How to proceed on the waypoint path?

Posted by Alpha Carinae on Game Development See other posts from Game Development or by Alpha Carinae
Published on 2013-10-08T10:01:47Z Indexed on 2013/11/07 16:14 UTC
Read the original article Hit count: 311

Filed under:

I'm using Dijkstra algorithm to find shortest path and I'm drawing this path on the screen. As the character object moves on, path updates itself(shortens as the object approaches the target and gets longer as the object moves away from it.) I tried to visualize my problem.

This is the beginning state. 'A' node is the target, path is the blue and the object is the green one.

enter image description here

I draw this path, from object to the closest node. In this case my problem occurs. Because 'D' node is more closer to the object than 'C' node, something like this happens:

enter image description here

So, how can i decide that the object passed the 'D' node? Path should be look like this:

enter image description here

One thing comes to my mind is that I use some distance variables between the two closest nodes in the route path. (In this example these are 'C' and 'D' nodes.) As the object approaches 'C' and moves away from the 'D' node at the same time, this means character passed the 'D'.

However, I think there are some standardized and easy ways to solve this. What approach should I take?

© Game Development or respective owner

Related posts about path-finding