Instance Method

connectNodeUsingObstacles:ignoringObstacles:

Adds the specified node to the graph, connecting it to its nearest neighbors while ignoring the area occupied by the specified obstacles.

Declaration

- (void)connectNodeUsingObstacles:(NodeType)node ignoringObstacles:(NSArray<GKPolygonObstacle *> *)obstaclesToIgnore;

Parameters

node

A graph node object containing 2D coordinate information.

obstaclesToIgnore

An array of obstacles to be ignored when adding the node to the graph.

Discussion

The GKObstacleGraph class automatically maintains a network of nodes that describes the navigable areas around its collection of obstacles. Adding a new node to the graph connects it to these nodes, such that the resulting network can be used to find paths around the obstacles to the position of the new node. GameplayKit adds new connections only if those connections do not represent a path through any obstacles (or through the buffer region around them, as specified by the bufferRadius property.)

Call this method when you need to to connect a node to the graph without taking certain obstacles into account. For example, you might add a node representing the destination for a game character to move toward, but place that node inside an existing obstacle, so that the resulting path gets the character as near to that obstacle as possible.

See Also

Working with Nodes

- connectNodeUsingObstacles:

Adds the specified node to the graph, connecting it to its nearest neighbors without creating connections that pass through obstacles or their buffer regions.

- connectNodeUsingObstacles:ignoringBufferRadiusOfObstacles:

Adds the specified node to the graph, connecting it to its nearest neighbors while ignoring the buffer regions around the specified obstacles.

bufferRadius

The distance from obstacle edges that should also be considered impassable.