Jump to content
  • Advertisement
Sign in to follow this  
Andreas Persson

Need help with wall avoidance

This topic is 4666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am currently develoing an AI enemy that walks around randomly in my level but now I need for him to avoid walking in to walls how do I do this? I am using directx and would appreciate all the help I can get [Edited by - Andreas Persson on January 1, 2006 10:33:48 AM]

Share this post


Link to post
Share on other sites
Advertisement
By using some kind of path finding algorithm. There are various algorithms around that are better suited to certain situations.

If your level is 3D and not based around tiles then a good method might be to add hidden entities to the level and use them as waypoints for the A.I. so that it can find its way around obstacles and walls etc.

If your level is tile based then an algorithm like A* might be better suited to the situation.

A quick search on google (or maybe even in the articles on gamedev) should find you plenty of examples of path finding algorithms. I have written an implementation of the A* algorithm in C++ if you would like to take a look at it.

Edit: also calling your thread "Need help" is frowned upon, try to use a descriptive title to do with the content of your thread.

Share this post


Link to post
Share on other sites
Yes I have looked at A* but I was more after some form of separation from the walls, let´s say that an enemy is wandering randomly in my world and he is heading towards a wall I want him to "feel" the wall and turn in another direction when he gets to close.

And thanks for the tip I changed it

Share this post


Link to post
Share on other sites
How about having a vector from the centre of your enemy, have its length equal to the minimum distance between your enemy and the walls/obstacles in the level, and have the direction the same as the enemy's direction. As your enemy is moving around the level you could check to see if this vector touches or goes through the walls in the level. If it does then turn both the enemy and the vector until there is some free space for movement.

Share this post


Link to post
Share on other sites
If you still need help, in a book I read the author projects 3 "feelers" out in front of the agent, one straight ahead, then at 45 degree angles to either side.
then, using a physics system he already had set up, he put a force on the agent in the direction perpendicular to the wall. the strength of the force was directly proportional to the distance the "feeler" had penetrated the wall, it works pretty good.
Hope this helps.
Svenjamin

I forgot, the length of the feelers is directly proportional to the agent's current velocity.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!