---
title: GKPath
framework: gameplaykit
role: symbol
role_heading: Class
path: gameplaykit/gkpath
---

# GKPath

A polygonal path that can be followed by an agent.

## Declaration

```swift
class GKPath
```

## Overview

Overview To make an agent move to or stay within the area defined by a path, create a goal with the init(toStayOn:maxPredictionTime:) method; to make an agent traverse along a path, create a goal with the init(toFollow:maxPredictionTime:forward:) method. A path can be expressed as a sequence of either 2D points or 3D points. Use the former to create paths for use by GKAgent2D objects, and the latter to create paths for GKAgent3D objects to follow. note: The coordinate system in which you express the path’s vertices and radius is arbitrary; you may choose how to map agent positions and sizes into your game scene. It often makes sense to use the same coordinate system as your game engine—for example, when using agents in a SpriteKit-based game, you’d typically specify a path in screen points. To learn more about using goals and agents, see Agents, Goals, and Behaviors in GameplayKit Programming Guide.

## Topics

### Creating a Path

- [init(graphNodes:radius:)](gameplaykit/gkpath/init(graphnodes:radius:).md)

### Managing a Path’s Attributes

- [radius](gameplaykit/gkpath/radius.md)
- [isCyclical](gameplaykit/gkpath/iscyclical.md)

### Inspecting a Path’s Shape

- [numPoints](gameplaykit/gkpath/numpoints.md)
- [float2(at:)](gameplaykit/gkpath/float2(at:).md)
- [float3(at:)](gameplaykit/gkpath/float3(at:).md)
- [point(at:)](gameplaykit/gkpath/point(at:).md)

### Initializers

- [init(points:radius:cyclical:)](gameplaykit/gkpath/init(points:radius:cyclical:)-6qqn4.md)
- [init(points:radius:cyclical:)](gameplaykit/gkpath/init(points:radius:cyclical:)-2iv4v.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.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

### 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)
- [GKAgentDelegate](gameplaykit/gkagentdelegate.md)
