[SOLVED] NavMesh node not a child of scene node

Dear everybody,
I use the town.zip scene from the tutorial.
I load the scene into SceneComposer, create a NavMesh with SceneComposer.
That NavMesh shows in the SceneExplorer. Behold:

However, when I try to access the NavMesh in the code, I get a null pointer. So it doesn’t find the mesh.

 public void printChildrenNames(Node n){
        for (Spatial child : n.getChildren()){
            System.out.println(child.getName());
        }
    }


Node n = (Node) demo;//thats main-scene_node

        printChildrenNames(n);
     
        Geometry geom = (Geometry) n.getChild("NavMesh");
        System.out.println(geom==null);
        
line 131->       System.out.println("mygame.Main.initSceneAndPlayer()"+geom.getName());
        Mesh m = geom.getMesh();
        NavMesh navMesh = new NavMesh(m);

Output of running the code:

Which is obvious, since geom is null.
Geom is null because there is only level as a child of main-scene_node.
But why does the SceneExplorer show the NavMesh node then?

I saved multiple times. I can load the scene and the navmesh is still there.

Can anyone help me, please? I am at a loss.

Best,
j

My guess would be that the scene in the SceneComposer and the one you load in your demo are not the same file. Possibly a classpath issue.
Is the scene in your assets folder? If not, try that.

2 Likes

Thanks, man!
The problem was indeed that I loaded the wrong data.
The program I am extending uses config files to load stuff. I didn’t change what has to be loaded in the file.
Once that was fixed, everything was okay.

1 Like