Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Sep 15 '11 at 4:07

This question came from our site for professional and enthusiast programmers.

2  
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" –  Drahakar Sep 15 '11 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 –  gladoscc Sep 15 '11 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? –  Jordaan Mylonas Sep 15 '11 at 4:37
    
possible duplicate of gamedev.stackexchange.com/questions/12959/… –  Ali.S Sep 15 '11 at 9:00

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
Regarding pathfinding - each node would be a polygon, or each node = X pixels (tile-based)? –  gladoscc Sep 15 '11 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. –  DampeS8N Sep 15 '11 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! –  gladoscc Sep 15 '11 at 12:38
    
I liked link to presentation of left4dead ai, maybe can you share some relational information (articles, code samples) Thanks in advance. –  bobenko Jan 23 '12 at 12:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.