Implemt diddy PathFinding with TiledMap

Monkey Forums/Monkey Beginners/Implemt diddy PathFinding with TiledMap

sionco(Posted 2014) [#1]
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'

therevills(Posted 2014) [#2]
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...

sionco(Posted 2014) [#3]
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
		mapWidth = width
		mapHeight = height
		diagonals = diag
		randomity = random

but it seems to work only some of the time, but maybe that's a problem with my code.:-)

therevills(Posted 2014) [#4]
Just committed a Tiled pathfinding example:

sionco(Posted 2014) [#5]
Thank you that's fantastic.
I'm still learning, and Diddy is great, you should have a donate button!

sionco(Posted 2014) [#6]
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.

therevills(Posted 2014) [#7]
I think you will need a path finding object per enemy.