Sign in to follow this  
deukalion

A* AStar How to follow the path generated?

Recommended Posts

Hey.

I've recently created a simple Pacman-style game with AI A* AStar pathfinding, but I don't know how to make the Enemy follow the path in the right way.

I have a problem with my AI A* Astar solution. Currently, my program generates the right path from Enemy to the Player. So there is a path to follow.

Is there a good way to "follow" the path that A* AStar finds? For etc, an algorithm that works well.

All the solutions I've come up with either fail or doesn't work as good as they should've.

Any suggestions on how to proceed?

Share this post


Link to post
Share on other sites
Once you have the list of points, pick the first one and go towards it. That may not look pretty, but it should work. You can then improve it by going to the farthest point to which you have a line of view, or by using steering behaviors to get more natural-looking movement.

If you are having trouble with the part about moving a character towards a point, perhaps you are missing some basic pieces in your program. Can you make your enemies walk already?

Share this post


Link to post
Share on other sites
How exactly are you storing the path?
How do you know the right path is generated but still don't know how to follow it?
How is your world built? Does it use a grid that matches up with your pathing grid?

Normally with a* you should be storing the tile you were on previously to get to the tile you're on. So all you have to do is start from the finish, and create a stack of all the points you walked on. Then what ever is using that path, just needs to head towards the point at the top of the stack, when they get there, pop that point from the stack and continue to the next one, until there are no more points to move to.

Maybe you could clarify your problem a little more.

Share this post


Link to post
Share on other sites
I assume you have a grid of values starting from 0 and the next node will have 1 bigger value and so on...

So when the code gets to the end, you backtrack the nodes. From the end node, you pick the adjacent node wich has the smallest value (there may be multiple, in that case you could just pick a random one of the same value nodes) and do that with the node you selected and so on, and then the bot would go through the set of nodes starting from the last node of the list you built while backtracking the path.

Share this post


Link to post
Share on other sites
I made a thread about something that might be related to your problem
[url="http://www.gamedev.net/topic/602665-ai-misses-the-checkpoint/"]Ai misses the checkpoint[/url]

several solutions were posted, so you might find your solution there.
your post wasnt very specific so it might not be what you're looking for

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this