2D Toolkit Forum

2D Toolkit => Support => Topic started by: dotty on March 10, 2013, 03:59:02 pm

Title: Has anyone used astar pathfinding with tile map?
Post by: dotty on March 10, 2013, 03:59:02 pm
I'm having trouble getting this working. The astar pathfinding unity plugin (http://www.arongranberg.com/astar/docs/index.php) the free version.

Has anyone used these together?
Title: Re: Has anyone used astar pathfinding with tile map?
Post by: dotty on March 12, 2013, 09:18:07 pm
Just an update on this. I got it working!

I created a gameObject and wrote a script which takes a tk2dTileMap object and a AstarPath object and did something like this...

Code: [Select]
// Get the tilemaps' collider layers' mesh
Mesh mesh = mapData.Layers[1].GetChunk(0,0).colliderMesh;

// Create a new mesh graph
NavMeshGraph newMeshGroup = new NavMeshGraph();
newMeshGroup.sourceMesh = mesh;

// Add it
aStar.astarData.AddGraph( newMeshGroup );

Title: Re: Has anyone used astar pathfinding with tile map?
Post by: cquinones on May 16, 2013, 12:21:52 am
Isn't the NavMeshGraph expecting the "walkable" area? If so, how is this working for you? I've defined colliders for the wall sprites, which would imply that these are the areas you can't pass through. If I'm not mistaken, this won't generate an area that the pathfinding objects can walk on.

Am I missing something here? If anyone else would like to comment on how to build a navigation mesh out of tk2d tile map data, I would greatly appreciate it.
Title: Re: Has anyone used astar pathfinding with tile map?
Post by: unikronsoftware on May 16, 2013, 09:49:05 am
You can simply add a ground plane for that.
The important thing is to use the mesh collider as dotty  instead of the render mesh - the render mesh which Unity uses by default is flat (as it is a sprite), and unusable with the navigation system.
Title: Re: Has anyone used astar pathfinding with tile map?
Post by: Artheus on November 13, 2013, 10:50:54 pm
Has anyone got this working with the grid graph?