---
title: GKMeshGraph
framework: gameplaykit
role: symbol
role_heading: Class
path: gameplaykit/gkmeshgraph
---

# GKMeshGraph

A navigation graph for 2D game worlds that creates a space-filling network for smooth pathfinding around obstacles.

## Declaration

```swift
class GKMeshGraph<NodeType> where NodeType : GKGraphNode2D
```

## Overview

Overview To use a mesh graph for pathfinding, add a collection of GKObstacle objects representing impassable areas and GKGraphNode2D objects representing points of interest (such as the current position of a game character and the location it needs to find a route to). Then use methods of the superclass GKGraph to find routes through the graph. Unlike the related GKObstacleGraph class, a mesh graph creates a space-filling network of graph nodes, resulting in paths that are smooth but not the most efficient. To learn more about graphs and pathfinding, see Pathfinding in GameplayKit Programming Guide.

## Topics

### Creating a Graph

- [init(bufferRadius:minCoordinate:maxCoordinate:nodeClass:)](gameplaykit/gkmeshgraph/init(bufferradius:mincoordinate:maxcoordinate:nodeclass:).md)
- [init(bufferRadius:minCoordinate:maxCoordinate:)](gameplaykit/gkmeshgraph/init(bufferradius:mincoordinate:maxcoordinate:).md)

### Working with Obstacles

- [obstacles](gameplaykit/gkmeshgraph/obstacles.md)
- [addObstacles(_:)](gameplaykit/gkmeshgraph/addobstacles(_:).md)
- [removeObstacles(_:)](gameplaykit/gkmeshgraph/removeobstacles(_:).md)

### Working with Nodes

- [connectUsingObstacles(node:)](gameplaykit/gkmeshgraph/connectusingobstacles(node:).md)
- [bufferRadius](gameplaykit/gkmeshgraph/bufferradius.md)

### Managing the Mesh

- [triangulate()](gameplaykit/gkmeshgraph/triangulate().md)
- [triangulationMode](gameplaykit/gkmeshgraph/triangulationmode.md)
- [triangle(at:)](gameplaykit/gkmeshgraph/triangle(at:).md)
- [triangleCount](gameplaykit/gkmeshgraph/trianglecount.md)

### Constants

- [GKMeshGraphTriangulationMode](gameplaykit/gkmeshgraphtriangulationmode.md)
- [GKTriangle](gameplaykit/gktriangle.md)

### Instance Methods

- [classForGenericArgument(at:)](gameplaykit/gkmeshgraph/classforgenericargument(at:).md)

### Initializers

- [init(nodes:)](gameplaykit/gkmeshgraph/init(nodes:).md)

## Relationships

### Inherits From

- [GKGraph](gameplaykit/gkgraph.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Pathfinding

- [GKGraph](gameplaykit/gkgraph.md)
- [GKObstacleGraph](gameplaykit/gkobstaclegraph.md)
- [GKGridGraph](gameplaykit/gkgridgraph.md)
- [GKGraphNode](gameplaykit/gkgraphnode.md)
- [GKGraphNode2D](gameplaykit/gkgraphnode2d.md)
- [GKGraphNode3D](gameplaykit/gkgraphnode3d.md)
- [GKGridGraphNode](gameplaykit/gkgridgraphnode.md)
