[SOLVED] How to use AnimComposer?

Hello, i am new to jmonkey (and to java overall), and lately started making my own game. The thing is i dont know how to use animComposer and any code i find on this topic isnt helpful to me as i cant really figure it out. Could anyone show me an example of simplest animation playing with animComposer?
(if this matters, my file is exported as .glb and imported into jmonkey so its .j3o, JME version 3.3)

1 Like

you are right, wiki still refer to 3.2 animation.

To see examples please do:

SDK → New Project → JME Tests(find it) → create → run animation tests and see their sourcecodes
(you can also see them directly on github page jmonkeyengine/jme3-examples/src/main/java/jme3test at master · jMonkeyEngine/jmonkeyengine · GitHub)

here some classes: jmonkeyengine/jme3-examples/src/main/java/jme3test/model/anim at master · jMonkeyEngine/jmonkeyengine · GitHub

for example TestAnimMigration.java show migration from 3.2 to 3.3 animation. (but since you exported model using 3.3 you no need use “AnimMigrationUtils.migrate(model);”)

Thank you, i will look into it right now!

okay,so the thing is my AnimComposer is null
and line 5. also returns null (probably because AnimComposer itself is null)

  1. Spatial enemySpatial= (assetManager.loadModel(“Models/boss/boss.j3o”));
  2. enemyNode = new Node(“Enemy Node”);
  3. enemyNode.attachChild(enemySpatial);
  4. enemyAnimComposer = enemyNode.getChild(“Cube”).getControl(AnimComposer.class); 5.enemyAnimComposer.setCurrentAction(“Spawn”);

the action in blender (exported as glb if that matters and loaded into jme 3.3 so it uses new anim system) is called “Spawn” so it should be ok.
what i noticed though is that in the “boss” model hierarchy there is a hierarchy like scene->armature->Cube and when i System.out.println(enemySpatial.getName()); it returns “Scene” rather than “Cube”. Could you help me figure it out please?

i’ve also tried other variation of line 4. like:
enemyAnimComposer = enemySpatial.getControl(AnimComposer.class);
And it is null too. Is it a problem with my code or jmonkey import or blender 2.9?

Moreover, i tried running some code from github repo you sent (with my model and action names) and it still throws nullPointerException

package mygame;

import com.jme3.anim.AnimComposer;
import com.jme3.anim.Joint;
import com.jme3.anim.SkinningControl;
import com.jme3.app.SimpleApplication;
import com.jme3.light.AmbientLight;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;

// @author Stephen Gold

public class Main extends SimpleApplication {

SkinningControl sControl;

public static void main(String... argv) {
    new Main().start();

public void simpleInitApp() {
    Node cgModel = (Node) assetManager.loadModel(
    cgModel.rotate(0f, -1f, 0f);

    AnimComposer composer = cgModel.getControl(AnimComposer.class);
    sControl = cgModel.getControl(SkinningControl.class);

    AmbientLight light = new AmbientLight();

public void simpleUpdate(float tpf) {
    for (Joint joint : sControl.getArmature().getJointList()) {
        Vector3f translation = joint.getLocalTranslation();
        if (!Vector3f.isValidVector(translation)) {
            String msg = "Invalid translation for joint " + joint.getName();
            throw new IllegalStateException(msg);


NullPointerException at “composer.setCurrentAction(“Spawn”);”

Heres a thread that should help you.

Skim past original poster questions to the responses from members.

Alright, problem solved:
the problem was model hierarchy, i was adressing “Cube” (the mesh itself) rather than Armature.001 which was the whole object
thank you guys!

like that:

enemyAnimComposer = enemyNode.getChild(“Armature.001”).getControl(AnimComposer.class);

1 Like