---
title: GKSphereObstacle
framework: gameplaykit
role: symbol
role_heading: Class
path: gameplaykit/gksphereobstacle
---

# GKSphereObstacle

A spherical impassable volume to be avoided by agents.

## Declaration

```swift
class GKSphereObstacle
```

## Overview

Overview To make agents (GKAgent objects) avoid obstacles, create a goal with the init(toAvoid:maxPredictionTime:) method. Agents affected by an avoid-obstacles goal will attempt to move such that their radius never overlaps that of a spherical obstacle. To learn more about using goals and agents, see Agents, Goals, and Behaviors in GameplayKit Programming Guide.

## Topics

### Creating an Obstacle

- [init(radius:)](gameplaykit/gksphereobstacle/init(radius:).md)

### Placing an Obstacle

- [position](gameplaykit/gksphereobstacle/position.md)
- [radius](gameplaykit/gksphereobstacle/radius.md)

## Relationships

### Inherits From

- [GKObstacle](gameplaykit/gkobstacle.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

- [GKObstacle](gameplaykit/gkobstacle.md)
- [GKCircleObstacle](gameplaykit/gkcircleobstacle.md)
- [GKPolygonObstacle](gameplaykit/gkpolygonobstacle.md)
