---
title: GKAgentDelegate
framework: gameplaykit
role: symbol
role_heading: Protocol
path: gameplaykit/gkagentdelegate
---

# GKAgentDelegate

Implement this protocol to synchronize the state of an agent with its visual representation in your game.

## Declaration

```swift
protocol GKAgentDelegate : NSObjectProtocol
```

## Overview

Overview A GKAgent object simulates its own movement according to constraints and goals. Use this protocol to manage an external object related to the agent, such as the sprite or 3D object that provides that agent’s visual representation in your game. You can synchronize with an agent in either or both directions: To update a visual representation based on the latest data from the agent simulation, implement the agentDidUpdate(_:) method. In this method you can read the position and rotation properties of the agent (as a GKAgent2D or GKAgent3D object) and set the corresponding attributes of whatever object provides the agent’s visual representation. To update the agent simulation with data from an external source—for example, if the game object corresponding to an agent is also affected by a physics engine such as those used in SpriteKit and SceneKit—implement the agentWillUpdate(_:) method. In this method you can set the position and rotation properties of the agent (as a GKAgent2D or GKAgent3D object) so that the next simulation step will take your changes to those properties into account. tip: If you use the GKSKNodeComponent class to manage the relationship between an entity and a SpriteKit node,  set your GKSKNodeComponent instance as the delegate for that entity’s agent, and GameplayKit will automatically synchronize the agent and its SpriteKit representation. To learn more about using goals and agents, see Agents, Goals, and Behaviors in GameplayKit Programming Guide.

## Topics

### Synchronizing with Agents

- [agentWillUpdate(_:)](gameplaykit/gkagentdelegate/agentwillupdate(_:).md)
- [agentDidUpdate(_:)](gameplaykit/gkagentdelegate/agentdidupdate(_:).md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

### Conforming Types

- [GKSCNNodeComponent](gameplaykit/gkscnnodecomponent.md)
- [GKSKNodeComponent](gameplaykit/gksknodecomponent.md)

## See Also

### Agents, Goals, and Behaviors

- [GKAgent](gameplaykit/gkagent.md)
- [GKAgent2D](gameplaykit/gkagent2d.md)
- [GKAgent3D](gameplaykit/gkagent3d.md)
- [GKGoal](gameplaykit/gkgoal.md)
- [GKBehavior](gameplaykit/gkbehavior.md)
- [GKCompositeBehavior](gameplaykit/gkcompositebehavior.md)
- [GKPath](gameplaykit/gkpath.md)
