Hi Unicron,
Before I kick into a big explanation, I’ll lead with:
I’m going to be releasing an addon for TTM that provides a bunch of movement scripts - both for players and AI, which will be integrated with the UI. So if anybody is reading the following example and feel a little like this O_O - never fear! ![]()
To get a path through a maze like p6r’s example, you can call:
Pathfinding.GetPath() via a script. This will return a list of PathNodes - which contain the x,y coordinates of the blocks you need to visit in order to move through this maze.
Once you have this list of nodes, you can call GetBlockAt(x,y,z) on the maze map to return the blocks themselves, which will yield the transforms you require to interpolate between.
The arguments aren’t documented yet (I’ve got a tonne of documentation in my “To Do” list) - but here’s a breakdown:
Your function call would look like this:
Pathfinding.GetPath(startX,startY,endX,endY,mazeMap,0,false,false,0,false);
To break that down:
The function is:
Pathfinding.GetPath(int x1, int y1, int x2, int y2, IPathMap pathMap, int depth, bool allowDiagonals, bool randomiseWeightMap, int randomisationAmount, bool pathOverAllBlocks)
x1 and y1 are the starting coordinates
x2 and y2 are the ending coordinates
pathMap is the map over which you wish to find a path (in this case, the maze)
depth is the layer depth at which you wish to path (if you are using a single-layered map, it would be 0)
allowDiagonals is a flag to tell pathfinding whether you want the paths to move diagonally. In a maze, this would be false, because your character would clip through walls on the diagonal movements.
The last three are related to generating levels:
randomiseWeightMap will return an imperfect path, for drawing paths that feel a little more organic
randomisationAmount tells the randomiser how much it should randomise by
pathOverAllBlocks tells the pathfinder to disregard pathing information and just go straight from A to B
In the next few smaller releases I’ll be neatening up the function calls a little, and adding documentation to the functions themselves. There’s so so so much to document, it will be a marathon ![]()
Hope that helps!
-JFFM

