Need help with wall avoidance
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]
Casual game dev www.apgames.se
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.
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.
Progress is born from the opportunity to make mistakes.
My prize winning Connect 4 AI looks one move ahead, can you beat it? @nickstadb
My prize winning Connect 4 AI looks one move ahead, can you beat it? @nickstadb
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
And thanks for the tip I changed it
Casual game dev www.apgames.se
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.
Progress is born from the opportunity to make mistakes.
My prize winning Connect 4 AI looks one move ahead, can you beat it? @nickstadb
My prize winning Connect 4 AI looks one move ahead, can you beat it? @nickstadb
Hm sounds like a good idea I´ll try it out thanks :)
Casual game dev www.apgames.se
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement