Class

# GKPath

A polygonal path that can be followed by an agent.

## Overview

To make an agent move to or stay within the area defined by a path, create a goal with the `goalToStayOnPath:maxPredictionTime:` method; to make an agent traverse along a path, create a goal with the `goalToFollowPath: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.

To learn more about using goals and agents, see Agents, Goals, and Behaviors in GameplayKit Programming Guide.

## Topics

### Creating a Path

`- initWithPoints:count:radius:cyclical:`

Initializes a path with the specified array of 2D points.

`+ pathWithPoints:count:radius:cyclical:`

Creates a path with the specified array of 2D points.

`- initWithFloat3Points:count:radius:cyclical:`

Initializes a path with the specified array of 3D points.

`+ pathWithFloat3Points:count:radius:cyclical:`

Creates a path with the specified array of 3D points.

`- initWithGraphNodes:radius:`

Initializes a path using the positions of the specified graph nodes.

`+ pathWithGraphNodes:radius:`

Creates a path using the positions of the specified graph nodes.

### Managing a Path’s Attributes

`radius`

`cyclical`

A Boolean value that determines whether the path loops around on itself (that is, the path’s end point connects to its start point).

### Inspecting a Path’s Shape

`numPoints`

The number of vertices in the path.

`- float2AtIndex:`

Returns the 2D point at the specified index in the path’s list of vertices.

`- float3AtIndex:`

Returns the 3D point at the specified index in the path’s list of vertices.

`- pointAtIndex:`

Returns the 2D point at the specified index in the path’s list of vertices.

Deprecated

## Relationships

### Agents, Goals, and Behaviors

`GKAgent`

A component that moves a game entity according to a set of goals and realistic constraints.

`GKAgent2D`

An agent that operates in a two-dimensional space.

`GKAgent3D`

An agent that operates in a three-dimensional space.

`GKGoal`

An influence that motivates the movement of one or more agents.

`GKBehavior`

A set of goals that together influence the movement of an agent.

`GKCompositeBehavior`

A set of behaviors, each of which is a set of goals, that together influence the movement of an agent.

`GKAgentDelegate`

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