How do I generate straight line path from A* path.
I've written game that use A* to calculate shortest path between two points in my two-dimension grid game,i can do this.But the path I get isn't the straight line (A* used for find shortest path,not the straight path) so my agent move queerness. So,I think I should use the straight-path because it make my agent look good when it move but I don't know how to do this.And I think it very difficult. Anyone who has ever done this,help me please.Or give me the advice for generate the straight-line-path from A* path. What algorithms should I use??? Thank you very much. Dong.
Assuming I understand your problem, one method for doing what you want is to examine each node in turn, and if there is a straight unobstructed line from the previous node to the next node, remove this node from the path.
But that will involve moving in such a way that you do not always remain aligned to the grid. Is that permissible in your system?
But that will involve moving in such a way that you do not always remain aligned to the grid. Is that permissible in your system?
You could change the weights in your pathing to consider a straighter line shorter. Perhaps you could subtract some distance from all blocks based on there distance from the straight line to the goal. You might get your AI moving some extra spaces here and there but it will probably look more natural.
In an empty space there will be several "shortest" paths instead of taking the first one you could check them all and select the straightest one.
Possibly the simplest method would be to use a simpler pathing algorithm first to check if there is a straight line to the goal. if there is, take it, if there isn't use A*.
I hope some of that helps...
In an empty space there will be several "shortest" paths instead of taking the first one you could check them all and select the straightest one.
Possibly the simplest method would be to use a simpler pathing algorithm first to check if there is a straight line to the goal. if there is, take it, if there isn't use A*.
I hope some of that helps...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement