void SetConnection(Vector3 position1, Vector3 position2)
{
AstarPath.active.AddWorkItem(new AstarWorkItem(ctx =>
{
// Connect two nodes
var node1 = AstarPath.active.GetNearest(position1, NNConstraint.None).node;
var node2 = AstarPath.active.GetNearest(position2, NNConstraint.None).node;
var cost = (uint) (node2.position - node1.position).costMagnitude;
node1.AddConnection(node2, cost);
node2.AddConnection(node1, cost);
node1.ContainsConnection(node2); // True
node1.RemoveConnection(node2);
node2.RemoveConnection(node1);
}));
}
I tried to use this technique to create narrow walls in my hex grid, but they still show a connections. Also, can I make one way connections?