<!--
{
  "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/GKPath/init(graphNodes:radius:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKPath(im)initWithGraphNodes:radius:"
  },
  "title" : "init(graphNodes:radius:)"
}
-->

# init(graphNodes:radius:)

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

```
init(graphNodes: [GKGraphNode], radius: Float)
```

## Parameters

`graphNodes`

An array of graph node objects containing 2D points.

`radius`

The radius of the path.

## Return Value

A new path object.

## Discussion

Use this initializer to turn a list of nodes from a navigation graph (as returned by the [`GKGraph`](/documentation/GameplayKit/GKGraph) [`findPath(from:to:)`](/documentation/GameplayKit/GKGraph/findPath(from:to:)) method) into a path-following goal for an agent. If the nodes are [`GKGraphNode2D`](/documentation/GameplayKit/GKGraphNode2D) objects, this initializer creates a 2D path; if the nodes are [`GKGraphNode3D`](/documentation/GameplayKit/GKGraphNode3D) objects, this initializer creates a 3D path.

The `radius` parameter defines the space occupied by the path—think of this space as the area created by sweeping a circle (or sphere, for 3D paths) of the specified radius along the path from vertex to vertex. Agents with path-related goals will attempt to move to or stay within this area.

To use the newly created path to constrain an agent’s behavior, create a goal with the [`init(toStayOn:maxPredictionTime:)`](/documentation/GameplayKit/GKGoal/init(toStayOn:maxPredictionTime:)) or [`init(toFollow:maxPredictionTime:forward:)`](/documentation/GameplayKit/GKGoal/init(toFollow:maxPredictionTime:forward:)) method.

---

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)