Function GraphNode.RemovePartialConnection

RemovePartialConnection (GraphNode node)

Removes any connection from this node to the specified node.

Public Abstract
void RemovePartialConnection (

GraphNode

node

)

Removes any connection from this node to the specified node.

If no such connection exists, nothing will be done.

Warning

In almost all cases, you should be using the Disconnect method instead. If you use this method, you must ensure that you preserve the required invariants of connections. Notably: If a connection exists from A to B, then there must also exist a connection from B to A. And their outgoing and incoming connection flags must be set symmetrically. Graphs sometimes use this method directly to improve performance in some situations.

AstarPath.active.AddWorkItem(new AstarWorkItem(ctx => {
// Connect two nodes
var node1 = AstarPath.active.GetNearest(transform.position, NNConstraint.None).node;
var node2 = AstarPath.active.GetNearest(transform.position + Vector3.right, NNConstraint.None).node;
var cost = (uint)(node2.position - node1.position).costMagnitude;
node1.AddPartialConnection(node2, cost, true, true);
node2.AddPartialConnection(node1, cost, true, true);

node1.ContainsOutgoingConnection(node2); // True

node1.RemovePartialConnection(node2);
node2.RemovePartialConnection(node1);
}));