Implemt diddy PathFinding with TiledMap
Monkey Forums/Monkey Beginners/Implemt diddy PathFinding with TiledMap
| ||
Hi, I'm trying to implement the Diddy PathFinding module with my tiled map, but I'm not sure what to use here, to acces a map created in Tiled PathFinder.SetMap(????, gameScreen.tilemap.width, gameScreen.tilemap.width, 2, 0) I want to check all the tiles in my CollisionLayer, I've tried things such as 'tilemap.tiles' |
| ||
Try this:Local layer:TileMapTileLayer = tileMap.FindLayerByName("COLLISION_LAYER") PathFinder.SetMap(layer.mapData.tiles, gameScreen.tilemap.width, gameScreen.tilemap.width, 2, 0) Not tested though... |
| ||
Thanks, but that gives me the error "Error : Cannot convert from Int[] to Float[]." I tried changing the pathFind Module to Function SetMap:Void(arr:Int[], width:Int, height:Int, diag:Int=1, random:Float=0) 'map = arr For Local i:Int = 0 To mapWidth For Local j:Int = 0 To mapHeight map[i*j]=arr[i*j] Next next mapWidth = width mapHeight = height diagonals = diag randomity = random End but it seems to work only some of the time, but maybe that's a problem with my code.:-) |
| ||
Just committed a Tiled pathfinding example: http://code.google.com/p/diddy/source/detail?r=322c5ed4894ab246e1318fcf5a4830ef3b24d60a |
| ||
Thank you that's fantastic. I'm still learning, and Diddy is great, you should have a donate button! |
| ||
is there any easy way to get this working for more than one object? for example, I have an array of three enemies, and the pathfinding only seems to work for the last one in the array. |
| ||
I think you will need a path finding object per enemy. |