NullException on adding animation listener

I’m trying to create animation for my player. It has few meshes (like helmet, body, shield etc.) and each mesh got it own animation. I wanna collect them all and use as a 1 animation : Walk.

I’m getting error: NullPointerException when trying to add Listener to channel.
Here’s tree of my model and code below:

[java]
player = (Node) assetManager.loadModel(“Models/Test/krzyzak6.j3o”);
player.setLocalScale(2.5f);
rootNode.attachChild(player);

/** Create a controller and channels. */  
control = player.getControl(AnimControl.class);
control.addListener(this);
channel = control.createChannel();
channel.addAllBones();
channel.setAnim("Walk");

}

public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
if (animName.equals(“Walk”)) {
channel.setAnim(“Walk”, 0.50f);
channel.setLoopMode(LoopMode.valueOf(“Walk”));
channel.setSpeed(3f);
}
}

public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
// unused
}

/** Custom Keybinding: Map named actions to inputs. */
private void initKeys() {
inputManager.addMapping(“Walk”, new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(actionListener, “Walk”);
}
private ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals(“Walk”) && !keyPressed) {
if (!channel.getAnimationName().equals(“Walk”)) {
channel.setAnim(“Walk”, 0.50f);
channel.setLoopMode(LoopMode.Loop);
}
}
}
};

}[/java]

There is no AnimControl on the root node so you obviously get null when you try to get it from there.

So I have to specify paths to all AnimControls and later add them all to control?

Ok I fix that but now got a small problem. All animControls got name: rigAction so I had to create 8 channels and 8 controls for all. Can I somehow now add all channels under 1 variable and just later call: variable.setAnim(“rigAction”) ?

You could make your own control that handles the other AnimControls and attach it to the model node to simplify working with one model.