I’m wondering if it is possible to get a list of nodes that have been modified in the OnGraphsUpdated callback?
Just a quick explanation as to why this would be useful for my needs:
I have an occupied matrix (bool[]) that I use to determine if a node is empty or not when spawning items. This is hooked up to my A* GridGraph in the sense that an index position in my matrix represents the occupied state of a GraphNode (matrix index == GraphNode.NodeIndex). Currently, when I update the AStarGraph I also make a separate call to update my matrix, where I determine the nodes that should be affected (with GetNodesInArea). This works great, but would be even better if I could handle this in OnGraphsUpdated callback instead.
The code wasn’t really intended for this, but it works fine.
You will have to make the GraphUpdateObject.changedNodes variable public.
var guo = new GraphUpdateObject(...); guo.trackChangedNodes = true; AstarPath.active.UpdateGraphs(guo); AstarPath.active.FlushGraphUpdates(); if ( guo.changedNodes != null ) { for ( int i = 0; i < guo.changedNodes.Count; i++ ) { // ... } }
But why don’t you just use the grid graph data which is already available.
GridGraph gg = AstarPath.active.gridGraph; for ( int i = 0; i < gg.nodes.Length; i++ ) { // ... }
When you say use the grid graph data available, do you mean to determine if a node is occupied or not instead of using my separate matrix? I was going to do that, but there are instances where there is an object on a node but the node is still walkable. For example, the user can place paths in the world, and this just changes the node’s penalty and tag. But I guess I can just check the tag, that could work. Thanks again!