GKObstacleGraph
A navigation graph for 2D game worlds that creates a minimal network for precise pathfinding around obstacles.
Declaration
class GKObstacleGraph<NodeType> where NodeType : GKGraphNode2DOverview
You create an obstacle graph with a collection of GKObstacle objects. To use the graph for pathfinding, you add 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 GKMeshGraph class, an obstacle graph creates a minimal network of graph nodes, resulting in paths that are efficient but not smooth.
To learn more about graphs and pathfinding, see Pathfinding in GameplayKit Programming Guide.
Topics
Creating a Graph
Working with Obstacles
Working with Nodes
connectUsingObstacles(node:)connectUsingObstacles(node:ignoring:)connectUsingObstacles(node:ignoringBufferRadiusOf:)bufferRadius