Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import GameplayKit
- var nodes = [GKGridGraphNode]()
- let maxSize = 3
- //Here I'm filling the elements of the grid
- for i in 0..<maxSize {
- for j in 0..<maxSize {
- let node = GKGridGraphNode(gridPosition: vector_int2(Int32(i), Int32(j)))
- nodes.append(node)
- }
- }
- let graph = GKGridGraph(nodes)
- let start = GKGridGraphNode(gridPosition: vector_int2(0,0))
- let end = GKGridGraphNode(gridPosition: vector_int2(2,2))
- let path = graph.findPath(from: start, to: end) //It returns an empty array
- print(path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement