<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKObstacleGraph/nodes(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKObstacleGraph(im)nodesForObstacle:"
  },
  "title" : "nodes(for:)"
}
-->

# nodes(for:)

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

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

## Parameters

`obstacle`

An obstacle in the graph.

## Return Value

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

## 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`](/documentation/GameplayKit/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)