---
title: GKObstacle
framework: gameplaykit
role: symbol
role_heading: Class
path: gameplaykit/gkobstacle
---

# GKObstacle

The abstract base class for objects representing impassable areas in a game world.

## Declaration

```swift
class GKObstacle
```

## Overview

Overview You do not use this class directly; instead, create instances of its concrete subclasses GKCircleObstacle, GKSphereObstacle, and GKPolygonObstacle. To make agents (GKAgent objects) avoid obstacles, create a goal with the goalToAvoidObstacles:timeBeforeCollisionToAvoid: method. To learn more about using goals and agents, see Agents, Goals, and Behaviors in GameplayKit Programming Guide. For more information, see GameplayKit Programming Guide.

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [GKCircleObstacle](gameplaykit/gkcircleobstacle.md)
- [GKPolygonObstacle](gameplaykit/gkpolygonobstacle.md)
- [GKSphereObstacle](gameplaykit/gksphereobstacle.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Obstacles

- [GKCircleObstacle](gameplaykit/gkcircleobstacle.md)
- [GKSphereObstacle](gameplaykit/gksphereobstacle.md)
- [GKPolygonObstacle](gameplaykit/gkpolygonobstacle.md)
