---
title: "nodes(for:)"
framework: gameplaykit
role: symbol
role_heading: Instance Method
path: "gameplaykit/gkobstaclegraph/nodes(for:)"
---

# nodes(for:)

Returns the group of nodes corresponding to an obstacle in the graph.

## Declaration

```swift
func nodes(for obstacle: GKPolygonObstacle) -> [NodeType]
```

## Parameters

- `obstacle`: An obstacle in the graph.

## Return Value

Return Value An array of nodes representing the navigable points nearest to each of the obstacle’s vertices.

## Discussion

Discussion Adding obstacles to a graph creates additional graph nodes corresponding to the navigable points nearest to each of the obstacle’s vertices. The GKObstacleGraph class automatically creates, removes, or rearranges these nodes where necessary, and automatically connects or disconnects other nodes so that no path between nodes passes through an obstacle.

## See Also

### Working with Obstacles

- [obstacles](gameplaykit/gkobstaclegraph/obstacles.md)
- [addObstacles(_:)](gameplaykit/gkobstaclegraph/addobstacles(_:).md)
- [removeObstacles(_:)](gameplaykit/gkobstaclegraph/removeobstacles(_:).md)
- [removeAllObstacles()](gameplaykit/gkobstaclegraph/removeallobstacles().md)
