Understanding AbstractControl to myself

i am trying to understand AbstractControl and i,ve make this short example but it won’t run whats the poblem , i,ve added image

below that what i do in this example and also Code
public class Main extends SimpleApplication implements ActionListener{
Node node1;
public static final String MAPPING_MOVE_RIGHT=“moveRight”;
public static final String MAPPING_MOVE_LEFT=“moveLeft”;
public static void main(String[] args) {
Main app = new Main();

public void simpleInitApp() {
   node1=new Node("boxNode");
   Box b = new Box(.5f, 3, .5f);
   Geometry  geom = new Geometry("Box", b);
   Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
   mat.setColor("Color", ColorRGBA.Blue);
   geom.setLocalTranslation(0, 1.5f, 0);
   node1.addControl(new Node_1_Control());
   inputManager.addMapping(MAPPING_MOVE_RIGHT,new KeyTrigger(KeyInput.KEY_K) );
   inputManager.addMapping(MAPPING_MOVE_LEFT,new KeyTrigger(KeyInput.KEY_L) );
   inputManager.addListener(this, "moveLeft","moveRight"); 

public void onAction(String name, boolean isPressed, float tpf) {
    else if(name.equals("moveRight")){node1.getControl(Node_1_Control.class).moveLeft=isPressed;}

public class Node_1_Control extends AbstractControl {
public boolean moveRight,moveLeft;

Node_1_Control() {
protected void controlUpdate(float tpf) {
    if(moveRight){spatial.rotate(0, 0, 4*tpf);
    }else if(moveLeft){spatial.rotate(0, 0, -4*tpf);

protected void controlRender(RenderManager rm, ViewPort vp) {


How doesn’t it run? Do you get a compile error? Runtime exception? Or does the application run but your spatial won’t rotate?


Or in other words: The integer 4 * tpf (something very small) equals 0. Change it to 4f.
How many times I’ve fallen into that trap.

Nevermind that, it’s the divisions that get you. I guess I just failed my Java certification course with that answer :wink:

1 Like

It looks like you never add the geometry to the node1… so you have an empty node in the scene graph and won’t see anything.

thank u rickard i remove tpf and my code run well

and thank u pspeed i did not add geom to node1