For those of you who don't know what it is, it is the best path finding system in Game Maker and used by lots of professional games. The included example shows just how effective it is. Provided their destination is valid (ex: not in an obstacle) there is an extremely good chance of getting there. Very good for top-down games with enemies following you or needing to get to another destination somehow.
A MUST for any top-down action game.
Help Document (Copied & Pasted):
A* Motion Planning
Game Maker Extension
This extension for Game Maker 7 adds actions to the object action library that use Game Maker's built in A* algorithm, normally accessed via scripting. This extension will automaticly handle the creation/deletion of paths (required to use the system), uses a single global grid (for simplicity), and adds a few easy to use functions such as filling a square area with a grid. More info on this system is inside the Game Maker help. Not all of Game Maker's functions for this motion planning system are available, however these may be added in with a later version.
If you script with Game Maker, you may find these actions somewhat redundant. Via scripting you'll have more control over these commands. These actions are aimed towards users who are new to Game Maker, who cannot script well, or would prefer and easier alternative to scripting.
Please check the included example to see the power of this motion planning and check out the objects to see just how easy it is to use with this extension.
This Game Maker Extension provides 11 new actions for use in objects or timelines. Each one contains its own unique icon. Relative
Setup Motion Planning Grid - Will allow you to setup a motion planning grid. Includes arguments for x & y position, horizontal cells, vertical cells, cell size x & y. Make sure you call this command (or the next) before using any of the other commands (except setup object for paths) or the game may crash.
Setup Motion Planning Grid (Fill Square) - Will allow you to setup a motion planning grid that fills a square. x & y (1,2) values work just like drawing a rectangle. Then fill in the cell size (x,y sizes are not seperate for this action). For example, you could place the x & y (1) values at 0,0, and x & y (2) values at room_width,room_height, and a cell size of 32 (for example) to fill the entire room. Note: The fill may not be exact depending on the size of the rectangle and size of cells.
Destroy Motion Planning Grid - Deletes the motion planning grid. The motion planning grid must exist.
Add All Instances to Grid - Adds all the instances in the room to the grid. This may not be ideal for most games.
Add All Instances of Object Type to Grid - All all the instances of the specified object type to the grid.
Add Object to Grid - Adds the current instance to the grid.
Setup Objects for Paths - Setups the object for the path system (defines local variables used by the extension). Must be called in create event.
Find a Path to Position - Finds a valid path to a position. If the path is inside an obstacle (object on grid) no path will be created.
Stop the Motion Path - Stops the current motion path. This may seem redudant, as the normal path stopping action will work, but this gives you the option to remove the last used path from memory (if it exists).
If the Instance is Stuck - Returns true if the instance isn't moving (stuck). This usually only happens if the destination is inside an obstacle on the grid.
Draw Grid Cells - Draws the grid cells. Should be used for debuging only. Blocked cells are in red, clear cells are green.
Remember to give credit to Airslide!
Edited by Airslide, 21 July 2007 - 12:56 PM.