Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

Path finding

Path finding

Ezbez
Ezbez
Ezbez's Blog · · 1 min read
1,330 1
Since the last update I've been working mostly on path finding. I thought I'd show an image of the pathfinding algorithm running.




The enemies (in red) show their paths (in magenta) calculated by A*. The large magenta dots show the furthest along target that the enemy can see - this is what it actually moves towards in order to take shorter, diagonal paths that A* doesn't find. You can see that the process still has some bugs in it - notice how two enemies are moving directly toward the player (in green) despite a wall being in the way.

One problem I encountered was that enemies kept on getting stuck on walls. This was due to their looking ahead and 'seeing' the waypoint just across the corner, when in actuality their non-zero radii meant that they would get trapped on the corner trying to take a diagonal path. To fix this, I used the common technique of enlarging all collision objects by the radius of the enemy before doing the line-of-sight test. Since I only use the static level geometry for line-of-sight tests, I simply make an enlarged version of it at level load.

Discussion

Loading comments...