2d Grid and tags

Hi

I just downloaded the FREE version to test 2d nav. I did a search and it was suggested to tags and penalties to weight a node. (ie: roads preferred over non roads).

But I can’t seem to get it to work.

The seeker has access to all tags, and ground tag’s penalty is 50000.
Tag 1’s penalty is 0.

I am setting the node’s tag to 1 by doing this:
AstarPath.active.data.gridGraph.nodes [ Y * AstarPath.active.data.gridGraph.width + X].Tag = 1;

But it doesn’t seem to affect pathing at all.

Hi

Can you verify that the graphs are being applied by setting A* Inspector -> Settings -> Debug -> Graph Coloring = Tags?

I see it as purple in the editor, is it applied correctly?

I found the problem.

I was doing Scan after setting the node, but the node’s tag was set manually.
After the scan, the nodes settings were wiped. That was why it didn’t work for me.

Ah. I see.
Glad you got it to work.

Btw, do you have an end date to the sale on unity?

I would like to test the free version before I buy it but don’t want to miss the deal with over testing.

It’s going to end pretty soon, but I do not know the exact date. It was actually going to end earlier this month, but there were some technical issues earlier which caused it to not show up, so I suppose they are letting it run a bit longer than originally planned.

So I have a tilemap and the a* grid is scanned base off that tilemap.
The tilemap can be changed during runtime so it needs a rescan after update to keep collisions up to date.

However, there are also tags which were created from script.
How can I rescan yet preserving the tags?

Is there a way to modify the scan to pick up a specific collider and assign a tag automatically?

Hi

You can use graph updates instead of scanning the whole grid. They can be configured to keep the previous penalty (using GraphUpdateObject.resetPenaltyOnPhysics=false): https://arongranberg.com/astar/docs/graph-updates.php
Another option that might be useful for you is to sublcass the grid graph: you can take a look at this thread: Tagging procedural 2D tiles

It works like magic! Thanks!

I am noticing a problem with UpdateGraphs, when I am calling this 1 at a time, it works without any problems. But if I have multiple “actors” that calls this from their own script and if it happens near the same time, it doesn’t update correctly.

ie: 5 different units cutting trees, when the tree is cut the graph needs to update. If 2 or more updates happen at the same time, some of the updates doesn’t occur.

Hi

What settings are you using on the GraphUpdateObject?
Updates are never skipped, so it must be something else that is happening.

I was basically doing this.
var guo = new GraphUpdateObject(myBounds);
guo.updatePhysics = false;
AstarPath.active.UpdateGraphs (guo);

I ditched guo completely and is now updating per node as my game is tilebased and it seems to work better because I am updating exactly the single node being modified.

there shouldn’t be any performance issue with frequent node updates right? (mobile game)

That shouldn’t even update anything. If you set updatePhysics to false and don’t tell it to make any other changes, then it will not do anything (except possibly update the erosion, but I don’t think that should matter in this case).

Ok. If you only have to update a single node then it might make more sense to do it that way.

In case you need some more information about that, here is the relevant doc page: https://arongranberg.com/astar/documentation/dev_4_1_2_41647108/graph-updates.php
That doc page is slightly more up-to-date than the documentation for the current release.

That depends. For all graph updates the pathfinding threads have to be paused, which can increase the time it takes for a path to be calculated (since no work can be done when the threads are paused). Unless your graph update takes a lot of time it shouldn’t cause any performance issues though.