Animations not working: NPE at ".getControl(AnimControl.class)"

Hello everyone,

today I tried to start with animations again, after focusing a lot on game dynamics/mechanics.
As always, it started off with a NPE. Great.

This is what I did:

  • make a model in Blender
  • export it as .blend
  • import it an convert it to .j3o (while doing this, I got triangulation warnings and “Animation found: ArmatureAction”)
  • Try if the model is displayed (it is)
  • Copy/Paste code from the beginner tutorial
    When getting the AnimControl, it returns null (which I find strange).

Here is what I did:

    public void simpleInitApp() {
        Node creature = (Node) assetManager.loadModel("Models/creature.j3o");
        animControl = creature.getControl(AnimControl.class);
        animControl.addListener((AnimEventListener) this);
        AnimChannel chl_walk = animControl.createChannel();

If you need more code or the model, feel free to ask.
I think there’s something wrong with importing, but I wanted to ask about the code anyway.

Likely the animation control is on a child of the node. View the model in scene explorer to see for sure.

1 Like

I didn’t think of that.
It works. Thanks.

(Holy crap, this problem got solved in 20 min)

1 Like