<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKSphereObstacle",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKSphereObstacle"
  },
  "title" : "GKSphereObstacle"
}
-->

# GKSphereObstacle

A spherical impassable volume to be avoided by agents.

```
class GKSphereObstacle
```

## Overview

To make agents ([`GKAgent`](/documentation/GameplayKit/GKAgent) objects) avoid obstacles, create a goal with the [`init(toAvoid:maxPredictionTime:)`](/documentation/GameplayKit/GKGoal/init(toAvoid:maxPredictionTime:)-7oslq) 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](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/Agent.html#//apple_ref/doc/uid/TP40015172-CH8) in [GameplayKit Programming Guide](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/index.html#//apple_ref/doc/uid/TP40015172).

## Topics

### Creating an Obstacle

[`init(radius:)`](/documentation/GameplayKit/GKSphereObstacle/init(radius:))

Initializes a spherical obstacle with the specified radius.

[`obstacleWithRadius:`](/documentation/GameplayKit/GKSphereObstacle/obstacleWithRadius:)

Creates a spherical obstacle with the specified radius.

### Placing an Obstacle

[`position`](/documentation/GameplayKit/GKSphereObstacle/position)

The position of the obstacle.

[`radius`](/documentation/GameplayKit/GKSphereObstacle/radius)

The radius of the 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)