Hi,
I was wondering what unit uses the Node Size property?
I’m doing a 2D tile-based game and I’d need node size to be about 48px square, So that they fit with my tilesystem, so for example a wall would give a non-walkable node.
I quickly made something to flag wall for my game, it works, I see the shape of my walls but they doesn’t fit with the walls at all. See here (bottom left of the game window) http://cl.ly/image/3J2X271K150s
Here’s the code I pulled to get it working:
`
private void AssignNodesToTiles() {
TileNodes = new TileNodeCollection();
GridGraph graph = AstarPath.active.astarData.gridGraph;
bool isFirst = false;
TileSystem[] tileSystems;
tileSystems = new TileSystem[3] { floor, wall1, wall2 };
foreach(TileSystem tileSystem in tileSystems) {
// looping on our pathfinder grid
for (int row = 0; row < tileSystem.rows; ++row) {
for (int column = 0; column < tileSystem.columns; ++column) {
TileData tile = tileSystem.GetTile(row, column);
if (tile == null)
continue;
GridNode node = (GridNode)graph.nodes[column*graph.width + row];
// if there's "Wall" in the tile name, expect it to be non-walkable
if (tile.TilesetBrush.name != null) {
if (tile.TilesetBrush.name.Contains("Wall")) {
node.walkable = false;
}
}
if (isFirst) {
// coords of the tile
Coords coords = new Coords(row, column);
// tile/node associationh
TileNodePair tileNodePair = new TileNodePair(tile, node);
TileNodes.Add(coords, tileNodePair);
}
}
}
}
}
`
It is functional but as I said the non walkable node does not fit with the walls on screen at all. Any suggestion for this?
Thanks a lot!