---
title: "addObstacles(_:)"
framework: gameplaykit
role: symbol
role_heading: Instance Method
path: "gameplaykit/gkobstaclegraph/addobstacles(_:)"
---

# addObstacles(_:)

Adds new obstacles to the graph.

## Declaration

```swift
func addObstacles(_ obstacles: [GKPolygonObstacle])
```

## Parameters

- `obstacles`: An array of obstacle objects to be added to the graph.

## Discussion

Discussion Adding a new obstacle to the graph has the same effect as if that obstacle were present when creating the graph—that is, the GKObstacleGraph class automatically creates new nodes and edges where necessary to describe the navigable area around the complete collection of obstacles.

## See Also

### Working with Obstacles

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