I have a non-tile-based top down shooter game, and I have enemies set up. However I need the enemies to move to the player. Pathfinding algorithms will mean the enemies will just hug the wall. The map has many walls and objects for cover.

How is it done in other games and what should I do?

  • 2
    \$\begingroup\$ Sorry but why would " Pathfinding algos will mean the enemies will just hug the wall." Pathfinding algorithm can be designed to open doors and avoid "hugging the wall" \$\endgroup\$
    – Drahakar
    Commented Sep 15, 2011 at 4:01
  • \$\begingroup\$ Umm, what should I use or do I have to make my own? Also the game is not tile based at all, not quite sure how to do that \$\endgroup\$
    – apscience
    Commented Sep 15, 2011 at 4:13
  • \$\begingroup\$ You will likely need to use different algorithms dependant on whether this is set indoors or outdoors. Is one setting more prominent than the other? \$\endgroup\$ Commented Sep 15, 2011 at 4:37
  • \$\begingroup\$ possible duplicate of gamedev.stackexchange.com/questions/12959/… \$\endgroup\$
    – Ali1S232
    Commented Sep 15, 2011 at 9:00

1 Answer 1


First of all if your map is not tile based, you need to create a navigation mesh out of it.

Second thing you will need is a good pathfinding algorithm. A* is a good one to start with.

Third you will need to add some intelligence to your pathfinding so it will go throught the doors that can be opened and avoid those who can't, I am sure you will find a way.

Fourth, if you want to make your AI look smarter you can smooth their path with some steering algorithm (or you can look at what valve did for left4dead)

And then I guess this would be a good start :)

  • \$\begingroup\$ Regarding pathfinding - each node would be a polygon, or each node = X pixels (tile-based)? \$\endgroup\$
    – apscience
    Commented Sep 15, 2011 at 5:02
  • \$\begingroup\$ @gladoscc: In your case a collection of points that represent the ideal locations to be walking through is the way to go. In the simplest case, the nodes would be simple objects with location data, and connections to other nodes. You could give each node a generic resistance value, and have A* use it when calculating the heuristic. You can make the center of halls the least resistive, which will make A* pick those nodes over the ones on the walls where possible. \$\endgroup\$
    – DampeS8N
    Commented Sep 15, 2011 at 11:42
  • \$\begingroup\$ I've decided to settle on waypoints, but there is some random variance. When the enemy can trace a direct line to the player, then the enemy just goes straight for the player. Thanks for the help! \$\endgroup\$
    – apscience
    Commented Sep 15, 2011 at 12:38
  • \$\begingroup\$ I liked link to presentation of left4dead ai, maybe can you share some relational information (articles, code samples) Thanks in advance. \$\endgroup\$
    – Yevhen
    Commented Jan 23, 2012 at 12:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .