# Enemy Movement AI

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?

• 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" Commented Sep 15, 2011 at 4:01
• 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 Commented Sep 15, 2011 at 4:13
• 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? Commented Sep 15, 2011 at 4:37
• possible duplicate of gamedev.stackexchange.com/questions/12959/… Commented Sep 15, 2011 at 9:00

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 :)

• Regarding pathfinding - each node would be a polygon, or each node = X pixels (tile-based)? Commented Sep 15, 2011 at 5:02
• @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. Commented Sep 15, 2011 at 11:42
• 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! Commented Sep 15, 2011 at 12:38
• I liked link to presentation of left4dead ai, maybe can you share some relational information (articles, code samples) Thanks in advance. Commented Jan 23, 2012 at 12:36