다음을 통해 공유


GKGraph.FindPath(GKGraphNode, GKGraphNode) 메서드

정의

최저 비용 순서 경로를 나타내는 T:GamplayKit.GKGraphNode 배열을 반환합니다. 경로가 없으면 빈 배열을 반환합니다.

[Foundation.Export("findPathFromNode:toNode:")]
public virtual GameplayKit.GKGraphNode[] FindPath (GameplayKit.GKGraphNode startNode, GameplayKit.GKGraphNode endNode);
abstract member FindPath : GameplayKit.GKGraphNode * GameplayKit.GKGraphNode -> GameplayKit.GKGraphNode[]
override this.FindPath : GameplayKit.GKGraphNode * GameplayKit.GKGraphNode -> GameplayKit.GKGraphNode[]

매개 변수

startNode
GKGraphNode
endNode
GKGraphNode

반환

특성

설명

다음은 간단한 그래프에서 경로 찾기를 보여 줍니다.

var a = GKGraphNode2D.FromPoint (new Vector2 (0, 5));
var b = GKGraphNode2D.FromPoint (new Vector2 (3, 0));
var c = GKGraphNode2D.FromPoint (new Vector2 (2, 6));
var d = GKGraphNode2D.FromPoint (new Vector2 (4, 6));
var e = GKGraphNode2D.FromPoint (new Vector2 (2, 5));
var f = GKGraphNode2D.FromPoint (new Vector2 (2, 2));

a.AddConnections (new [] { b, c }, false);
b.AddConnections (new [] { e, f }, false);
c.AddConnections (new [] { d }, false);
d.AddConnections (new [] { e, f }, false);

var graph = GKGraph.FromNodes(new [] { a, b, c, d, e, f });

var a2e = graph.FindPath (a, e); // [ a, c, d, e ]
var a2f = graph.FindPath (a, f); // [ a, b, f ]

적용 대상