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?
A* AStar How to follow the path generated?
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?
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?
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.
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.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
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.
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.
o3o
I made a thread about something that might be related to your problem
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement