After adding a control, the other returns a null exception?

Hi guys!

Today i decided to add a PhysicsControl (with the SceneExplorer) to my terrain, to make a walking character. When i added that control, the TerrainLodControl starts to throw NullPointerExceptions:

[java]terreno.getChild(“terrain_Terreno”).getControl(TerrainLodControl.class).setCamera(cam);[/java]

I already tested the getChild() method and it works. When i try to get the lod control, it crashes.

The exception:

Set 20, 2014 7:51:19 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at mygame.Main.simpleInitApp(Main.java:121)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)

Can somebody explain me what i did wrong?

That’s your code throwing the NPE… not the terrain control.

I will assume that it’s the line you posted that is the one in your Main.simpleInit() where the exception is happening.

2 seconds in a debugger would tell you exactly what the issue is but it’s either that getChild() is returning null or that getControl() is returning null. An assumption somewhere on your part is faulty.

I really don’t know what happened, but i discovered the error: the terrain_Terreno changed to terreno-Terreno! OMG i feel so stupid now… but i don’t know why it changed the name. Anyways, thanks!