AnimControl null

I looked at all the other threads that had this problem, tried there solutions and nothing worked for me. I imported an animation from blender and it works perfect in the scene composer. In my code, i have:
Spatial an = model.getChild(“2”);

            control = an.getControl(AnimControl.class);
            control.addListener(this);
            channel = control.createChannel();

The child named 2 is the parent of the AnimControl in the scene composer hierarchy. My hierarchy is baseNode > Armature > LeftArm > 1 > 2 > Geometry, Skeleton and AnimControl. For some reason control is null no matter what I try.

Open the model in the SDK and look in the SceneExplorer where the actual AnimControl is (there might be multiple).

@normen said: Open the model in the SDK and look in the SceneExplorer where the actual AnimControl is (there might be multiple).

By the actual animcontrol I am assuming you mean the one that has the animations I can click on and play? I only have one of them

Yes, if you see them in the SDK you apparently access them wrong in your code. Maybe you try to get it from the root of the model while its actually attached to a child or so.

@normen said: Yes, if you see them in the SDK you apparently access them wrong in your code. Maybe you try to get it from the root of the model while its actually attached to a child or so.
That is what I originally thought. However, I accessed the lowest child node to get the animation and still null. The parent of the animControl is "2" so I do, getChild("2").getControl.... There's honestly nothing else I can think of that could be wrong. I'll try using different children to see if the SDK might be displaying the location incorrectly

can you show a screen shot of the scene explorer tree showing where your anim control is?

@pspeed said: can you show a screen shot of the scene explorer tree showing where your anim control is?

I finally figured the problem. I animated one model and got the anim control in my class, but I created multiple classes in my world each with a different model with no animation so those are the ones that were now, I am having an issue with the kinematic rag doll. I got the ogre character to work but my own rigged model gets a NPE when I attach the control. The bones and everything exported fine.

See, if you just tell us what you think you do we won’t get further, I guess if you thought you did something wrong you’d do it differently :slight_smile:

Referring to your first post with the code:

Spatial an = model.getChild(“2″);

From:

The art of node hopping while avoiding children: http://hub.jmonkeyengine.org/forum/topic/i-cant-load-my-own-model-t-t/page/2/

@kamran said: When you do Node.getChild(0) it is getting the first child of that node, when you do Node.getChild(1) then you will get the second child of the node assuming the node have two children for example lets say this is the hierarchy of a scene:

Node1
-Node2
–Node3
—AnimControl

If I would do Node1.getChild(0) then I would get Node2 which does not contain the AnimControl but If i do ((Node)Node1.getChild(0)).getChild(0) then I am going to get Node3 which contains the AnimControl. When I do Node1.getChild(“Node3”) then it is going to return the first child node with the name Node3. I hope that helps :slight_smile:

Hop on in that thread and give him some props for that nice explanation. Because I was doing it wrong too.

Of course I’m only assuming you’re making the same mistake I made with the getChild(int)