Hello, it s very long i didn t come back here
Today my question is about how to implement a graph in 2D only on some path i decided to.
Normally, in the examples, it s the contrary, you put obstacles
For me everything is an obstacle, except where i want the AI to be able to walk in
So i found a solution using my tiles with a layer, using them as an obstacle first, and then updating all nodes by telling that s the contrary.
It works but i was wandering if there is an other solution where i could put directly where i want the graph to work only
here is my code
AstarPath.active.Scan();
AstarPath.active.AddWorkItem(new AstarWorkItem(ctx =>
{
var gg = AstarPath.active.data.gridGraph;
for (var y = 0; y < gg.Depth; y++)
for (var x = 0; x < gg.Width; x++)
{
var node = gg.GetNode(x, y);
node.Walkable = !node.Walkable;
}
gg.GetNodes(node => gg.CalculateConnections((GridNodeBase)node));
}));
thanks for your time