Dynamically updating node tags


#1

Another silly question. I think i’m doing the recommended thing based on my attempt to find a similar question in the forum, but i’m still running into issues.

In my project i’m procedurally generating a 2d tilemap dungeon and using an array that holds what room that tile is in. I can update all the tags correctly by looping through all the nodes with:

graph.GetNodes(node => {
Vector3 nPosition = (Vector3)node.position;
//Code to get matching Tilemap.Tile
node.Tag = tile.GetRoom();
});
AstarPath.active.UpdateGraphs(collider.bounds);

When using the ProceduralGridMover scrip and either adding some code or trying to override the RecalculateCell so I don’t have to rescan the entire graph (very noticeable processing lag) I keep having issues getting the node position. It looks like the (Vector3)node.position = GraphPointToWorld process is returning positions with only one decimal point and my tiles are 0.64x0.64 so nothing is matching up.

I cant quite figure out why i can get the correct positions to begin with and not later on.


#2

Hi

(Vector3)node.position should return the correct world space position. When you print it using e.g. Debug.Log it may only print out one decimal point however, but you can print more using something like

Debug.Log(((Vector3)node.position).ToString("0.000000"));

Also note that the package only supports up to 32 tags (there are ways to modify the code to get more of them though).