Hello,
Is there a way to get a nearest node that considers a hidden connection?
Here is what I have…
As shown in the image, the soldier needs to get to point “A”, so the Pathfinding calculates “C” as the nearest node, which is correct.
But how can I configurate Astar so the Pathfinding returns “B” as the nearest node?
My approach is to assign a different tag to the destroyable blocks, so the Pathfinding consider them in the proximity calculation (but without allowing the soldier to walk by them).
I’m tagging the destroyable blocks using this custom GraphUpdateObject…
public class DestroyableGUO : GraphUpdateObject { public override void Apply(Node node) { // Set tag "Destroyable" node.tags = 3; } }
And every time I update the graph I execute…
`foreach (GameObject destructibleEntity in destructibleEntities)
{
GraphUpdateObject guo = new DestroyableGUO();
guo.bounds = destructibleEntity.transform.GetChild(0).collider.bounds;
AstarPath.active.UpdateGraphs(guo);
}`
Where destructibleEntities is an ArrayList of the destroyable blocks.
To this part, everything is working.
Then, to find the nearest node I use this custom NNConstraint
NNConstraint nn = NNConstraint.Default; nn.constrainArea = true; nn.area = nearestToSoldier.area; // Soldier's node area nn.constrainTags = true; nn.tags = (1 << 1 | 1 << 3 | 1 << 4); // 1: "Ground", 3: "Destroyable", 4: "Collectable"
But It doesn’t work
Am I going in the right direction?, Is there a way to do what I need?, or do I have to think in a workaround?
Thank you for your time!