rootNode.attachChild in onAnalog

Hi Guys…

My game is occasionally crashing with the exception

java.lang.ArrayIndexOutOfBoundsException: 2
    at com.jme3.util.SafeArrayList.get( 
    at com.jme3.renderer.RenderManager.renderSubScene(

which i understand is because i have been changing the scene graph out-side the main update loop… (im in process of fixing these)

But according to to the wiki i can only make changes in

“only in Control.update(), AppState.update(), or SimpleApplication.simpleUpdate()”

So what about onAnalog and onAction?

public class RealTimeStrategyAppState extends AbstractAppState implements ActionListener, AnalogListener{

    public void onAnalog(String name, float value, float tpf) {

    public void onAction(String name, boolean isPressed, float tpf) {


Is it ok for me to change the scene graph here?
Or is this bad as well?

Yes, it’s ok. All Input stuff is processed on the update thread as well.

1 Like

Technically if you dont start a Thread nearly anything is on the MainThread.

If you have multithreading make use of App.enqueue