<!--
{
  "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/GKAgent2D",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKAgent2D"
  },
  "title" : "GKAgent2D"
}
-->

# GKAgent2D

An agent that operates in a two-dimensional space.

```
class GKAgent2D
```

## Overview

Agents are game entities that move according to realistic constraints and whose behavior is determined by goals that motivate movement. The general functionality of an agent is defined by the abstract superclass [`GKAgent`](/documentation/GameplayKit/GKAgent); however, you use instances of the [`GKAgent2D`](/documentation/GameplayKit/GKAgent2D) class to implement agent-based gameplay in a 2D game (or in a 3D game where gameplay-relevant movement is restricted to two dimensions).

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

### Managing an Agent’s Position and Orientation

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

The current position of the agent in 2D space.

[`rotation`](/documentation/GameplayKit/GKAgent2D/rotation)

The rotation of the agent around the z-axis.

### Running the Agent Simulation

[`-  updateWithDeltaTime:`](/documentation/GameplayKit/GKAgent2D/update(deltaTime:))

Causes the agent to evaluate its goals and update its position, rotation, and velocity accordingly.

[`velocity`](/documentation/GameplayKit/GKAgent2D/velocity)

The current velocity of the agent in 2D space.

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

### Inherits From

[`GKAgent`](/documentation/GameplayKit/GKAgent)

---

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)