How to access the object of Navigation graph in spirit scene editor

I am working with spritkit and draw a scene by the help of spirit scene editor in xcode. According to spritkit, we can use Navigation graph to draw the paths and I can able to draw path using navigation graph but i can't able to access this object in swift back-end. May I know why?.







[![enter image description here][1]][1]





[1]: https://i.stack.imgur.com/2CSlE.png





How to access this graph object from this scene.

Replies

The Navigation Graph element must be loaded separately within your SKScene subclass. For example, with the code:


        let sceneFile = "GameScene"
        if let gkScene = GKScene( fileNamed: sceneFile ) {
            print( "graphs = \(gkScene.graphs)" )
        } else {
            print( "failed to create gkScene from file \(sceneFile)" )
        }


..which prints:

graphs = ["graph1": <GKGraph: 0x17403bda0>]


Where the navigable graph has the name "graph1" defined in the SpriteKit editor [seen in this screenshot].