control = player.getControl(AnimControl.class); returns null

I have previously made a simple model with animation and been able to import it as .j3o with success.

Using the HelloAnim tutorial I swapped my model name and action name and it worked.

This time however, with another model, I get a nullpointerexception where

control = player.getControl(AnimControl.class);

returns null.

this piece of code is part of the HelloAnim tutorial as of

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_animation

is there something wrong with my model file since it doesn’t have a control?

The animation works in blender and the model imports fine into JME. It can also display the model when running if I comment out the rest of the code so as not to cause the nullpointerexception.

UPDATE: Found some other similar threads so I’ll fill in
The scene explorer shows the model as having an AnimControl and my action “Action.001” is there, too. Nothing happens when I press “Play” in the scene explorer though,

Picture of the hierarchy that doesn’t work ( gghost) and the one that does work (Cube.001-ogremesh)

Ok, I seem to reach the control by doing this

control = player.getChild(“Cube”).getControl(AnimControl.class);
control.addListener(this);
channel = control.createChannel();
channel.setAnim(“Action.001”);

Now, there is no crash but animation still doesn’t play. Any idea?

The model I had that works can play its animation in teh scene composer.
The one that doesn’t work, doesn’t play in the scene composer.

Since the working model was exported via OGRE -> J3o I tried ogre exporting the non working one, and got this from Blender

I’m trying to manually select vertices and set their parents to just 1 bone, but that moves the skeleton around in a bad way.

UPDATE: Solved the ERROR by CTRL+A Location on the model and the armature. Still got vertex error though, working on it.

Ok So I solved this by learning how to manually assign vertexes to bones.

removed all vertex groups that were auto-created by the heat function of parent assign,

then created a vertex group for each foot and assigned the vertices of the feet to them (and same for the legs). then created one vertex group for the head and assigned the head vertices to that, and so on.
The vertex group has to have the same name as the bone.

The pose animation is only for the skeleton and completely separated from the mesh, didn’t realise that before. It all depends on how you assign vertices to each bone.

Great! I learned something.

UPDATE: I might add that after assigning those vertices to bones correctly , the oger exporter no longer gives error/warning.
I didn’t actually use the ogre export, I loaded the blender directly into jme and convert to j3o. Ogre still good for error checking.
After this, the animation plays in jme scene composer which indicates it is good, and indeed it plays in the jme and on the android, too.

2 Likes