# A* AStar How to follow the path generated?

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

## 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 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 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 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 on other sites
Ai misses the checkpoint

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

1. 1
2. 2
Rutin
21
3. 3
JoeJ
18
4. 4
5. 5

• 14
• 39
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631717
• Total Posts
3001877
×