aiFew weeks ago, i have done a post on how doing a smarter pathfinding for I.A. from results given by A*.

Someone asked me to show some code, so you will find below the method I use in my game. It is very rough but if you are a developer and you want to improve yourself on this subject, this will help you even if you can’t use it out of the box.

The method findPath() called in the first line is an A* implementation which gives a list of tiles index to reach the target modelized as a GridPoint2 objects. The “smarter” method returns a list of Vector2 objects which are real 2D coordinates in my world. Notice that the “area” parameter object passed to the method represent the surface of the sprite located at (x,y) which want to reach the target point (tx,ty). The area is relative to the position of the sprite. The parameter “collisionDetector” is an utility object which can check if the tile is solid or not (like a wall).