Here is an example of tag manipulation that took me a bit to figure out. This should work for the planet/ocean dilemma @phil.atha mentioned by simply measuring the distance of each node from the planetCenter and setting it to my ocean tag (1) if it’s shorter then the landRadius…
@chocominyo perhaps a similar approach could help you having an obstacle check if nodes are within an obstacle’s bounds?
public NavMeshGraph NMG;
public GameObject Planet;
public Vector3 planetCenter;
public int LandRadius;
public void SetNodes()
NMG = AstarPath.active.data.navmesh;
planetCenter = Planet.transform.position;
for (int z = 0; z < NMG.tileZCount; z++)
for (int x = 0; x < NMG.tileXCount; x++)
NavmeshTile tile = NMG.GetTile(x, z);
for (int i = 0; i < tile.nodes.Length; i++)
GraphNode node = tile.nodes[i];
tileV3 = (Vector3)node.position;
float dist = Vector3.Distance(planetCenter, tileV3);
if (dist <=LandRadius)
// tile.nodes[i].Walkable = false;
tile.nodes[i].Tag = 1;
//tile.nodes[i].Walkable = true;
tile.nodes[i].Tag = 0;
first if there are any glaring problems with this forgive me. I’m not a great coder AT ALL lol. This took me an embarrassing long time to figure out. I suppose if its for sure a navmesh type then the first two for loops could be done away with and use the line:
NavmeshTile tile = NMG.GetTile(0, 0);
as NavmeshGraphs only have one tile, right?
This above approach left me with some questions however… the line " NMG = AstarPath.active.data.navmesh;" gets the first navmesh type graph on the main A* component. What is an easy way to get a specific navmeshgraph from say 5 different navmesh graphs in one scene?
Also for say an “obstacle” that can set tags within it’s bounds how can one keep a list of nodes affected by it to later reset them once it is moved? Hmmm, maybe just have each obstacle use a list of bools that correspond to each node and cycle through em?
Any recommendations as far as optimally getting nodes within a volume? Thx