What is "myLevel" in NavMesh example code?

What class is “myLevel” in the following code?

[java]Mesh mesh = myLevel.getGeometry(“NavMesh”).getMesh();
NavMesh navMesh = new NavMesh(mesh);[/java]

I’ve already generated a NavMesh for my scene’s terrain by right clicking the terrain > Add Spatial > Nav Mesh. However, I don’t know how I’m going to access the NavMesh.

I load the scene using:

[java]Spatial ground = assetManager.loadModel(“Scenes/testScene.j3o”);[/java]

What do I do next to access the Nav Mesh?

Many Thanks!

Is “ground” your level?

If so then “ground” is “myLevel”.

Rename “myLevel” to “ground” and you are good to go. (and load the ‘ground’ spatial first)

Yup! ground is my level.

Do Spatial’s have the “getGeometry()” method? When I typed “ground.” there was no “getGeometry” method.

Thanks again!

You just need to get the navigation mesh off the geometry, like you would if you wanted to modify it.

getChild(“NavMesh”); is actually what you want to find a spatial that is a child of a node. The scene (“ground”) will be a node, so you will have to cast it to that first.